mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 21:10:56 +01:00
Make all parsers use credentials
Summary: We need to issue all commands as $repository->junk() so we can pick up credentials. Some of this stuff predates that change landing. (I removed the "https" vs "svn+ssh" fallback code since it's specific to Facebook, affected a tiny number of commits, is basically an SVN bug with UTF-8 handling and HTTP support, and doesn't make sense in the general case. The user has the tools they need to force it via "reparse.php" if it's really an issue.) Test Plan: Created new authenticated-remote mercurial and git repositories and pulled/discovered them with credentials. Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran Reviewed By: Makinde CC: aran, Makinde Differential Revision: 970
This commit is contained in:
parent
b1e1b1f9bd
commit
07f4772d0b
13 changed files with 51 additions and 66 deletions
|
@ -32,10 +32,8 @@ class PhabricatorRepositoryGitCommitDiscoveryDaemon
|
|||
|
||||
$repository_phid = $repository->getPHID();
|
||||
|
||||
$repo_base = $repository->getDetail('local-path');
|
||||
list($stdout) = execx(
|
||||
'(cd %s && git branch -r --verbose --no-abbrev)',
|
||||
$repo_base);
|
||||
list($stdout) = $repository->execxLocalCommand(
|
||||
'branch -r --verbose --no-abbrev');
|
||||
|
||||
$branches = DiffusionGitBranchQuery::parseGitRemoteBranchOutput($stdout);
|
||||
|
||||
|
@ -57,7 +55,6 @@ class PhabricatorRepositoryGitCommitDiscoveryDaemon
|
|||
$insert = array();
|
||||
|
||||
$repository = $this->getRepository();
|
||||
$repo_base = $repository->getDetail('local-path');
|
||||
|
||||
$discover[] = $commit;
|
||||
$insert[] = $commit;
|
||||
|
@ -66,9 +63,8 @@ class PhabricatorRepositoryGitCommitDiscoveryDaemon
|
|||
|
||||
while (true) {
|
||||
$target = array_pop($discover);
|
||||
list($parents) = execx(
|
||||
'(cd %s && git log -n1 --pretty="%%P" %s)',
|
||||
$repo_base,
|
||||
list($parents) = $repository->execxLocalCommand(
|
||||
'log -n1 --pretty="%%P" %s',
|
||||
$target);
|
||||
$parents = array_filter(explode(' ', trim($parents)));
|
||||
foreach ($parents as $parent) {
|
||||
|
@ -93,9 +89,8 @@ class PhabricatorRepositoryGitCommitDiscoveryDaemon
|
|||
|
||||
while (true) {
|
||||
$target = array_pop($insert);
|
||||
list($epoch) = execx(
|
||||
'(cd %s && git log -n1 --pretty="%%at" %s)',
|
||||
$repo_base,
|
||||
list($epoch) = $repository->execxLocalCommand(
|
||||
'log -n1 --pretty="%%at" %s',
|
||||
$target);
|
||||
$epoch = trim($epoch);
|
||||
|
||||
|
|
|
@ -10,7 +10,5 @@ phutil_require_module('phabricator', 'applications/diffusion/query/branch/git');
|
|||
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
|
||||
phutil_require_module('phabricator', 'applications/repository/daemon/commitdiscovery/base');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryGitCommitDiscoveryDaemon.php');
|
||||
|
|
|
@ -29,7 +29,6 @@ class PhabricatorRepositoryMercurialCommitDiscoveryDaemon
|
|||
|
||||
$repository_phid = $repository->getPHID();
|
||||
|
||||
$repo_base = $repository->getDetail('local-path');
|
||||
list($stdout) = $repository->execxLocalCommand('branches');
|
||||
|
||||
$branches = ArcanistMercurialParser::parseMercurialBranches($stdout);
|
||||
|
|
|
@ -29,8 +29,8 @@ class PhabricatorRepositorySvnCommitDiscoveryDaemon
|
|||
|
||||
$uri = $this->getBaseSVNLogURI();
|
||||
list($xml) = $repository->execxRemoteCommand(
|
||||
' log --xml --quiet --limit 1 %s@HEAD',
|
||||
$uri);
|
||||
'log --xml --quiet --limit 1 %s@HEAD',
|
||||
$uri);
|
||||
|
||||
$results = $this->parseSVNLogXML($xml);
|
||||
$commit = key($results);
|
||||
|
|
|
@ -23,12 +23,22 @@ final class PhabricatorRepositoryGitFetchDaemon
|
|||
return PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
|
||||
}
|
||||
|
||||
protected function executeCreate($remote_uri, $local_path) {
|
||||
execx('git clone %s %s', $remote_uri, rtrim($local_path, '/'));
|
||||
protected function executeCreate(
|
||||
PhabricatorRepository $repository,
|
||||
$local_path) {
|
||||
|
||||
$repository->execxRemoteCommand(
|
||||
'clone %s %s',
|
||||
$repository->getRemoteURI(),
|
||||
rtrim($local_path, '/'));
|
||||
}
|
||||
|
||||
protected function executeUpdate($remote_uri, $local_path) {
|
||||
execx('(cd %s && git fetch --all)', $local_path);
|
||||
protected function executeUpdate(
|
||||
PhabricatorRepository $repository,
|
||||
$local_path) {
|
||||
|
||||
$repository->execxLocalCommand(
|
||||
'fetch --all');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,5 @@
|
|||
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
|
||||
phutil_require_module('phabricator', 'applications/repository/daemon/pulllocal');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryGitFetchDaemon.php');
|
||||
|
|
|
@ -23,12 +23,20 @@ final class PhabricatorRepositoryMercurialPullDaemon
|
|||
return PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL;
|
||||
}
|
||||
|
||||
protected function executeCreate($remote_uri, $local_path) {
|
||||
execx('hg clone %s %s', $remote_uri, rtrim($local_path, '/'));
|
||||
protected function executeCreate(
|
||||
PhabricatorRepository $repository,
|
||||
$local_path) {
|
||||
$repository->execxRemoteCommand(
|
||||
'clone %s %s',
|
||||
$repository->getRemoteURI(),
|
||||
rtrim($local_path, '/'));
|
||||
}
|
||||
|
||||
protected function executeUpdate($remote_uri, $local_path) {
|
||||
execx('(cd %s && hg pull -u)', $local_path);
|
||||
protected function executeUpdate(
|
||||
PhabricatorRepository $repository,
|
||||
$local_path) {
|
||||
$repository->execxLocalCommand(
|
||||
'pull -u');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,5 @@
|
|||
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
|
||||
phutil_require_module('phabricator', 'applications/repository/daemon/pulllocal');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryMercurialPullDaemon.php');
|
||||
|
|
|
@ -20,8 +20,12 @@ abstract class PhabricatorRepositoryPullLocalDaemon
|
|||
extends PhabricatorRepositoryDaemon {
|
||||
|
||||
abstract protected function getSupportedRepositoryType();
|
||||
abstract protected function executeCreate($remote_uri, $local_path);
|
||||
abstract protected function executeUpdate($remote_uri, $local_path);
|
||||
abstract protected function executeCreate(
|
||||
PhabricatorRepository $repository,
|
||||
$local_path);
|
||||
abstract protected function executeUpdate(
|
||||
PhabricatorRepository $repository,
|
||||
$local_path);
|
||||
|
||||
final public function run() {
|
||||
$repository = $this->loadRepository();
|
||||
|
@ -45,7 +49,6 @@ abstract class PhabricatorRepositoryPullLocalDaemon
|
|||
}
|
||||
|
||||
$local_path = $repository->getDetail('local-path');
|
||||
$remote_uri = $repository->getDetail('remote-uri');
|
||||
|
||||
if (!$local_path) {
|
||||
throw new Exception("No local path is available for this repository.");
|
||||
|
@ -53,13 +56,10 @@ abstract class PhabricatorRepositoryPullLocalDaemon
|
|||
|
||||
while (true) {
|
||||
if (!Filesystem::pathExists($local_path)) {
|
||||
if (!$remote_uri) {
|
||||
throw new Exception("No remote URI is available.");
|
||||
}
|
||||
execx('mkdir -p %s', dirname($local_path));
|
||||
$this->executeCreate($remote_uri, $local_path);
|
||||
$this->executeCreate($repository, $local_path);
|
||||
} else {
|
||||
$this->executeUpdate($remote_uri, $local_path);
|
||||
$this->executeUpdate($repository, $local_path);
|
||||
}
|
||||
$this->sleep($repository->getDetail('pull-frequency', 15));
|
||||
}
|
||||
|
|
|
@ -67,26 +67,10 @@ abstract class PhabricatorRepositoryCommitParserWorker
|
|||
$verbose = '--verbose';
|
||||
}
|
||||
|
||||
try {
|
||||
list($xml) = $this->repository->execxRemoteCommand(
|
||||
"log --xml {$verbose} --limit 1 %s@%d",
|
||||
$uri,
|
||||
$revision);
|
||||
} catch (CommandException $ex) {
|
||||
// HTTPS is generally faster and more reliable than svn+ssh, but some
|
||||
// commit messages with non-UTF8 text can't be retrieved over HTTPS, see
|
||||
// Facebook rE197184 for one example. Make an attempt to fall back to
|
||||
// svn+ssh if we've failed outright to retrieve the message.
|
||||
$fallback_uri = new PhutilURI($uri);
|
||||
if ($fallback_uri->getProtocol() != 'https') {
|
||||
throw $ex;
|
||||
}
|
||||
$fallback_uri->setProtocol('svn+ssh');
|
||||
list($xml) = execx(
|
||||
"svn log --xml {$verbose} --limit 1 --non-interactive %s@%d",
|
||||
$fallback_uri,
|
||||
$revision);
|
||||
}
|
||||
list($xml) = $this->repository->execxRemoteCommand(
|
||||
"log --xml {$verbose} --limit 1 %s@%d",
|
||||
$uri,
|
||||
$revision);
|
||||
|
||||
// Subversion may send us back commit messages which won't parse because
|
||||
// they have non UTF-8 garbage in them. Slam them into valid UTF-8.
|
||||
|
|
|
@ -11,8 +11,6 @@ phutil_require_module('phabricator', 'applications/repository/storage/repository
|
|||
phutil_require_module('phabricator', 'infrastructure/daemon/workers/worker');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'parser/uri');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -30,12 +30,11 @@ class PhabricatorRepositoryGitCommitChangeParserWorker
|
|||
return;
|
||||
}
|
||||
|
||||
$local_path = $repository->getDetail('local-path');
|
||||
|
||||
list($raw) = execx(
|
||||
'(cd %s && git log -n1 -M -C -B --find-copies-harder --raw -t '.
|
||||
'--abbrev=40 --pretty=format: %s)',
|
||||
$local_path,
|
||||
// NOTE: "--pretty=format: " is to disable log output, we only want the
|
||||
// part we get from "--raw".
|
||||
list($raw) = $repository->execLocalCommand(
|
||||
'log -n1 -M -C -B --find-copies-harder --raw -t '.
|
||||
'--abbrev=40 --pretty=format: %s',
|
||||
$commit->getCommitIdentifier());
|
||||
|
||||
$changes = array();
|
||||
|
|
|
@ -11,7 +11,5 @@ phutil_require_module('phabricator', 'applications/repository/storage/repository
|
|||
phutil_require_module('phabricator', 'applications/repository/worker/commitchangeparser/base');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryGitCommitChangeParserWorker.php');
|
||||
|
|
Loading…
Reference in a new issue