Refactor repository reparse scripts to be more useful
Summary: Splitting up D960 a bit, see that for context. We currently have two scripts, "parse_one_commit.php" and "reparse_all_commit_messages.php", but they're sort of silly and you can't do certain things with them. Replace them with one script which is more flexible and can do specific reparse steps on individual commits or entire repos. I left the old scripts as stubs since I think there are some FB wiki docs and stuff that mention them. I'll delete them in a month or whenever I remember or something. Test Plan: Ran "reparse.php" with various arguments, including vs-one-commit, vs-repository, with --trace, and against different types of repos. Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran Reviewed By: jungejason CC: aran, jungejason Differential Revision: 964
This commit is contained in:
@@ -17,69 +17,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$root = dirname(dirname(dirname(__FILE__)));
|
||||
require_once $root.'/scripts/__init_script__.php';
|
||||
require_once $root.'/scripts/__init_env__.php';
|
||||
|
||||
if (empty($argv[1])) {
|
||||
echo "usage: parse_one_commit.php <commit_name> [--herald]\n";
|
||||
die(1);
|
||||
}
|
||||
|
||||
$commit = isset($argv[1]) ? $argv[1] : null;
|
||||
if (!$commit) {
|
||||
throw new Exception("Provide a commit to parse!");
|
||||
}
|
||||
$matches = null;
|
||||
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $commit, $matches)) {
|
||||
throw new Exception("Can't parse commit identifier!");
|
||||
}
|
||||
$repo = id(new PhabricatorRepository())->loadOneWhere(
|
||||
'callsign = %s',
|
||||
$matches[1]);
|
||||
if (!$repo) {
|
||||
throw new Exception("Unknown repository!");
|
||||
}
|
||||
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
|
||||
'repositoryID = %d AND commitIdentifier = %s',
|
||||
$repo->getID(),
|
||||
$matches[2]);
|
||||
if (!$commit) {
|
||||
throw new Exception('Unknown commit.');
|
||||
}
|
||||
|
||||
$workers = array();
|
||||
|
||||
$spec = array(
|
||||
'commitID' => $commit->getID(),
|
||||
'only' => true,
|
||||
);
|
||||
|
||||
switch ($repo->getVersionControlSystem()) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||
$workers[] = new PhabricatorRepositoryGitCommitMessageParserWorker(
|
||||
$spec);
|
||||
$workers[] = new PhabricatorRepositoryGitCommitChangeParserWorker(
|
||||
$spec);
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
$workers[] = new PhabricatorRepositorySvnCommitMessageParserWorker(
|
||||
$spec);
|
||||
$workers[] = new PhabricatorRepositorySvnCommitChangeParserWorker(
|
||||
$spec);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unknown repository type!");
|
||||
}
|
||||
|
||||
if (isset($argv[2]) && $argv[2] == '--herald') {
|
||||
$workers[] = new PhabricatorRepositoryCommitHeraldWorker($spec);
|
||||
}
|
||||
|
||||
foreach ($workers as $worker) {
|
||||
echo "Running ".get_class($worker)."...\n";
|
||||
$worker->doWork();
|
||||
}
|
||||
|
||||
echo "Done.\n";
|
||||
|
||||
echo "This script is obsolete. Instead, use:\n\n".
|
||||
" $ reparse.php <commit_name> --message --change\n\n".
|
||||
"See that script for more options.\n";
|
||||
exit(1);
|
||||
|
||||
Reference in New Issue
Block a user