mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Fix some argument parsing stuff in reparse.php
Summary: Currently, "reparse.php --message rXnnn" fails because $reparse_what is an array. Allow multiple named commits. Test Plan: $ ./scripts/repository/reparse.php --message rP9030fe8b0904b5291c69a22b0570a10013bba4b2 rP81946fc08d8a737b278255090e296ca92164d672 Running 'PhabricatorRepositoryGitCommitMessageParserWorker'... Running 'PhabricatorRepositoryGitCommitMessageParserWorker'... Done. Reviewers: nh, vrana, btrahan Reviewed By: nh CC: aran Differential Revision: https://secure.phabricator.com/D3362
This commit is contained in:
parent
287fc75bb0
commit
d9f241a9ca
1 changed files with 26 additions and 27 deletions
|
@ -94,14 +94,10 @@ $force = $args->getArg('force');
|
|||
$force_local = $args->getArg('force-local');
|
||||
$min_date = $args->getArg('min-date');
|
||||
|
||||
if (count($reparse_what) > 1 || !($all_from_repo xor count($reparse_what))) {
|
||||
if (!$all_from_repo && !$reparse_what) {
|
||||
usage("Specify a commit or repository to reparse.");
|
||||
}
|
||||
|
||||
if ($args->getArg('trace')) {
|
||||
PhutilServiceProfiler::installEchoListener();
|
||||
}
|
||||
|
||||
if (!$reparse_message && !$reparse_change && !$reparse_herald &&
|
||||
!$reparse_owners) {
|
||||
usage("Specify what information to reparse with --message, --change, ".
|
||||
|
@ -146,29 +142,32 @@ if ($all_from_repo) {
|
|||
}
|
||||
$callsign = $repository->getCallsign();
|
||||
} else {
|
||||
$matches = null;
|
||||
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $reparse_what, $matches)) {
|
||||
throw new Exception("Can't parse commit identifier!");
|
||||
$commits = array();
|
||||
foreach ($reparse_what as $identifier) {
|
||||
$matches = null;
|
||||
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $identifier, $matches)) {
|
||||
throw new Exception("Can't parse commit identifier!");
|
||||
}
|
||||
$callsign = $matches[1];
|
||||
$commit_identifier = $matches[2];
|
||||
$repository = id(new PhabricatorRepository())->loadOneWhere(
|
||||
'callsign = %s',
|
||||
$callsign);
|
||||
if (!$repository) {
|
||||
throw new Exception("No repository with callsign '{$callsign}'!");
|
||||
}
|
||||
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
|
||||
'repositoryID = %d AND commitIdentifier = %s',
|
||||
$repository->getID(),
|
||||
$commit_identifier);
|
||||
if (!$commit) {
|
||||
throw new Exception(
|
||||
"No matching commit '{$commit_identifier}' in repository ".
|
||||
"'{$callsign}'. (For git and mercurial repositories, you must specify ".
|
||||
"the entire commit hash.)");
|
||||
}
|
||||
$commits[] = $commit;
|
||||
}
|
||||
$callsign = $matches[1];
|
||||
$commit_identifier = $matches[2];
|
||||
$repository = id(new PhabricatorRepository())->loadOneWhere(
|
||||
'callsign = %s',
|
||||
$callsign);
|
||||
if (!$repository) {
|
||||
throw new Exception("No repository with callsign '{$callsign}'!");
|
||||
}
|
||||
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
|
||||
'repositoryID = %d AND commitIdentifier = %s',
|
||||
$repository->getID(),
|
||||
$commit_identifier);
|
||||
if (!$commit) {
|
||||
throw new Exception(
|
||||
"No matching commit '{$commit_identifier}' in repository '{$callsign}'. ".
|
||||
"(For git and mercurial repositories, you must specify the entire ".
|
||||
"commit hash.)");
|
||||
}
|
||||
$commits = array($commit);
|
||||
}
|
||||
|
||||
if ($all_from_repo && !$force_local) {
|
||||
|
|
Loading…
Reference in a new issue