Skip to content

Commit d9f241a

Browse files
author
epriestley
committed
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
1 parent 287fc75 commit d9f241a

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

scripts/repository/reparse.php

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,10 @@
9494
$force_local = $args->getArg('force-local');
9595
$min_date = $args->getArg('min-date');
9696

97-
if (count($reparse_what) > 1 || !($all_from_repo xor count($reparse_what))) {
97+
if (!$all_from_repo && !$reparse_what) {
9898
usage("Specify a commit or repository to reparse.");
9999
}
100100

101-
if ($args->getArg('trace')) {
102-
PhutilServiceProfiler::installEchoListener();
103-
}
104-
105101
if (!$reparse_message && !$reparse_change && !$reparse_herald &&
106102
!$reparse_owners) {
107103
usage("Specify what information to reparse with --message, --change, ".
@@ -146,29 +142,32 @@
146142
}
147143
$callsign = $repository->getCallsign();
148144
} else {
149-
$matches = null;
150-
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $reparse_what, $matches)) {
151-
throw new Exception("Can't parse commit identifier!");
152-
}
153-
$callsign = $matches[1];
154-
$commit_identifier = $matches[2];
155-
$repository = id(new PhabricatorRepository())->loadOneWhere(
156-
'callsign = %s',
157-
$callsign);
158-
if (!$repository) {
159-
throw new Exception("No repository with callsign '{$callsign}'!");
160-
}
161-
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
162-
'repositoryID = %d AND commitIdentifier = %s',
163-
$repository->getID(),
164-
$commit_identifier);
165-
if (!$commit) {
166-
throw new Exception(
167-
"No matching commit '{$commit_identifier}' in repository '{$callsign}'. ".
168-
"(For git and mercurial repositories, you must specify the entire ".
169-
"commit hash.)");
145+
$commits = array();
146+
foreach ($reparse_what as $identifier) {
147+
$matches = null;
148+
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $identifier, $matches)) {
149+
throw new Exception("Can't parse commit identifier!");
150+
}
151+
$callsign = $matches[1];
152+
$commit_identifier = $matches[2];
153+
$repository = id(new PhabricatorRepository())->loadOneWhere(
154+
'callsign = %s',
155+
$callsign);
156+
if (!$repository) {
157+
throw new Exception("No repository with callsign '{$callsign}'!");
158+
}
159+
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
160+
'repositoryID = %d AND commitIdentifier = %s',
161+
$repository->getID(),
162+
$commit_identifier);
163+
if (!$commit) {
164+
throw new Exception(
165+
"No matching commit '{$commit_identifier}' in repository ".
166+
"'{$callsign}'. (For git and mercurial repositories, you must specify ".
167+
"the entire commit hash.)");
168+
}
169+
$commits[] = $commit;
170170
}
171-
$commits = array($commit);
172171
}
173172

174173
if ($all_from_repo && !$force_local) {

0 commit comments

Comments
 (0)