mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-23 14:00:55 +01:00
Parse full URIs for "Differential Revision" in Arcanist
Summary: - Allow Arcanist to parse either "123", "D123" (existing behaviors) or "http://phabricator.example.com/D123" (new behavior) values. - Drop support for labeling this field "DiffCamp". This should only impact people trying to update revisions that are more than ~a year old, which should be very very few. Test Plan: - Ran "arc diff" with values "74", "D74", "x74", "http://local.aphront.com/D74", "http://local.aphront.com/x74". Got the expected behaviors. Reviewers: jungejason, btrahan Reviewed By: jungejason CC: aran, jungejason Maniphest Tasks: T54, T692 Differential Revision: 1249
This commit is contained in:
parent
52d14ef8e6
commit
89cb92a22c
3 changed files with 35 additions and 8 deletions
|
@ -35,10 +35,29 @@ class ArcanistDifferentialCommitMessage {
|
|||
$obj = new ArcanistDifferentialCommitMessage();
|
||||
$obj->rawCorpus = $corpus;
|
||||
|
||||
// TODO: Remove "Diffcamp" backward compatibility.
|
||||
// Parse older-style "123" fields, or newer-style full-URI fields.
|
||||
// TODO: Remove support for older-style fields.
|
||||
|
||||
$match = null;
|
||||
if (preg_match('/^(?:Differential|DiffCamp) Revision:\s*D?(\d+)/im', $corpus, $match)) {
|
||||
$obj->revisionID = (int)$match[1];
|
||||
if (preg_match('/^Differential Revision:\s*(.*)/im', $corpus, $match)) {
|
||||
$revision_id = trim($match[1]);
|
||||
if (strlen($revision_id)) {
|
||||
if (preg_match('/^D?\d+$/', $revision_id)) {
|
||||
$obj->revisionID = (int)trim($revision_id, 'D');
|
||||
} else {
|
||||
$uri = new PhutilURI($revision_id);
|
||||
$path = $uri->getPath();
|
||||
$path = trim($path, '/');
|
||||
if (preg_match('/^D\d+$/', $path)) {
|
||||
$obj->revisionID = (int)trim($path, 'D');
|
||||
} else {
|
||||
throw new ArcanistUsageException(
|
||||
"Invalid 'Differential Revision' field. The field should have a ".
|
||||
"Phabricator URI like 'http://phabricator.example.com/D123', ".
|
||||
"but has '{$match[1]}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pattern = '/^git-svn-id:\s*([^@]+)@(\d+)\s+(.*)$/m';
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
|
||||
|
||||
phutil_require_module('arcanist', 'exception/usage');
|
||||
|
||||
phutil_require_module('phutil', 'parser/uri');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -499,11 +499,16 @@ EOTEXT
|
|||
'differential.createrevision',
|
||||
$revision);
|
||||
$result = $future->resolve();
|
||||
echo "Updating commit message to include Differential revision ID...\n";
|
||||
$repository_api->amendGitHeadCommit(
|
||||
$message->getRawCorpus().
|
||||
"\n\n".
|
||||
"Differential Revision: ".$result['revisionid']."\n");
|
||||
|
||||
$revised_message = $conduit->callMethodSynchronous(
|
||||
'differential.getcommitmessage',
|
||||
array(
|
||||
'revision_id' => $result['revisionid'],
|
||||
));
|
||||
|
||||
echo "Updating commit message...\n";
|
||||
$repository_api->amendGitHeadCommit($revised_message);
|
||||
|
||||
echo "Created a new Differential revision:\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue