mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
make arc patch workflow preserve author commit information
Summary: assumes D3917 (or something like it that populates 'author' value from conduit call) exists in production Test Plan: stubbed out 'author' value and verified checkins as author worked Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T479 Differential Revision: https://secure.phabricator.com/D3918
This commit is contained in:
parent
02b185571f
commit
827c1bc1c5
4 changed files with 64 additions and 5 deletions
|
@ -16,6 +16,15 @@ final class ArcanistBundle {
|
|||
private $revisionID;
|
||||
private $encoding;
|
||||
private $loadFileDataCallback;
|
||||
private $author;
|
||||
|
||||
public function setAuthor($author) {
|
||||
$this->author = $author;
|
||||
return $this;
|
||||
}
|
||||
public function getAuthor() {
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
public function setConduit(ConduitClient $conduit) {
|
||||
$this->conduit = $conduit;
|
||||
|
@ -85,6 +94,7 @@ final class ArcanistBundle {
|
|||
$base_revision = idx($meta_info, 'baseRevision');
|
||||
$revision_id = idx($meta_info, 'revisionID');
|
||||
$encoding = idx($meta_info, 'encoding');
|
||||
$author = idx($meta_info, 'author');
|
||||
// this arc bundle was probably made before we started storing meta info
|
||||
} else {
|
||||
$version = 0;
|
||||
|
@ -92,6 +102,7 @@ final class ArcanistBundle {
|
|||
$base_revision = null;
|
||||
$revision_id = null;
|
||||
$encoding = null;
|
||||
$author = null;
|
||||
}
|
||||
|
||||
$future = new ExecFuture(
|
||||
|
@ -165,11 +176,12 @@ final class ArcanistBundle {
|
|||
}
|
||||
|
||||
$meta_info = array(
|
||||
'version' => 3,
|
||||
'version' => 4,
|
||||
'projectName' => $this->getProjectID(),
|
||||
'baseRevision' => $this->getBaseRevision(),
|
||||
'revisionID' => $this->getRevisionID(),
|
||||
'encoding' => $this->getEncoding(),
|
||||
'author' => $this->getAuthor(),
|
||||
);
|
||||
|
||||
$dir = Filesystem::createTemporaryDirectory();
|
||||
|
|
|
@ -828,6 +828,7 @@ abstract class ArcanistBaseWorkflow {
|
|||
$bundle->setProjectID($diff['projectName']);
|
||||
$bundle->setBaseRevision($diff['sourceControlBaseRevision']);
|
||||
$bundle->setRevisionID($diff['revisionID']);
|
||||
$bundle->setAuthor($diff['author']);
|
||||
return $bundle;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ final class ArcanistExportWorkflow extends ArcanistBaseWorkflow {
|
|||
public function getCommandSynopses() {
|
||||
return phutil_console_format(<<<EOTEXT
|
||||
**export** [__paths__] __format__ (svn)
|
||||
**export** [__commit_range__] __format__ (git)
|
||||
**export** [__commit_range__] __format__ (git, hg)
|
||||
**export** __--revision__ __revision_id__ __format__
|
||||
**export** __--diff__ __diff_id__ __format__
|
||||
EOTEXT
|
||||
|
@ -35,7 +35,7 @@ EOTEXT
|
|||
|
||||
public function getCommandHelp() {
|
||||
return phutil_console_format(<<<EOTEXT
|
||||
Supports: git, svn
|
||||
Supports: svn, git, hg
|
||||
Export the local changeset (or a Differential changeset) to a file,
|
||||
in some __format__: git diff (__--git__), unified diff
|
||||
(__--unified__), or arc bundle (__--arcbundle__ __path__) format.
|
||||
|
@ -181,12 +181,36 @@ EOTEXT
|
|||
$this->getArgument('paths'));
|
||||
$diff = $repository_api->getFullGitDiff();
|
||||
$changes = $parser->parseDiff($diff);
|
||||
$authors = $this->getConduit()->callMethodSynchronous(
|
||||
'user.query',
|
||||
array(
|
||||
'phids' => array($this->getUserPHID()),
|
||||
));
|
||||
$author_dict = reset($authors);
|
||||
$author = sprintf('%s <%s>',
|
||||
$author_dict['realName'],
|
||||
$repository_api->execxLocal('config user.email'));
|
||||
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
||||
$repository_api->parseRelativeLocalCommit(
|
||||
$this->getArgument('paths'));
|
||||
$diff = $repository_api->getFullMercurialDiff();
|
||||
$changes = $parser->parseDiff($diff);
|
||||
$authors = $this->getConduit()->callMethodSynchronous(
|
||||
'user.query',
|
||||
array(
|
||||
'phids' => array($this->getUserPHID()),
|
||||
));
|
||||
$author_dict = reset($authors);
|
||||
$author = sprintf('%s <%s>',
|
||||
$author_dict['realName'],
|
||||
$repository_api->execxLocal('showconfig ui.username'));
|
||||
} else {
|
||||
// TODO: paths support
|
||||
$paths = $repository_api->getWorkingCopyStatus();
|
||||
$changes = $parser->parseSubversionDiff(
|
||||
$repository_api,
|
||||
$paths);
|
||||
$author = $this->getUserName();
|
||||
}
|
||||
|
||||
$bundle = ArcanistBundle::newFromChanges($changes);
|
||||
|
@ -194,6 +218,7 @@ EOTEXT
|
|||
$bundle->setBaseRevision(
|
||||
$repository_api->getSourceControlBaseRevision());
|
||||
// note we can't get a revision ID for SOURCE_LOCAL
|
||||
$bundle->setAuthor($author);
|
||||
break;
|
||||
case self::SOURCE_REVISION:
|
||||
$bundle = $this->loadRevisionBundleFromConduit(
|
||||
|
|
|
@ -706,9 +706,24 @@ EOTEXT
|
|||
}
|
||||
|
||||
if ($this->shouldCommit()) {
|
||||
// git is really, really finicky about the author information so we
|
||||
// make sure it is in the
|
||||
// "George Washington <gwashington@example.com> format or don't use it.
|
||||
$author_cmd = '';
|
||||
$author = $bundle->getAuthor();
|
||||
if ($author) {
|
||||
$address = new PhutilEmailAddress($author);
|
||||
if ($address->getDisplayName() && $address->getAddress()) {
|
||||
$author = sprintf('%s <%s>',
|
||||
$address->getDisplayName(),
|
||||
$address->getAddress());
|
||||
$author_cmd = sprintf('--author=%s ', $author);
|
||||
}
|
||||
}
|
||||
$commit_message = $this->getCommitMessage($bundle);
|
||||
$future = $repository_api->execFutureLocal(
|
||||
'commit -a -F -');
|
||||
'commit -a %C-F -',
|
||||
$author_cmd);
|
||||
$future->write($commit_message);
|
||||
$future->resolvex();
|
||||
$verb = 'committed';
|
||||
|
@ -758,9 +773,15 @@ EOTEXT
|
|||
}
|
||||
|
||||
if ($this->shouldCommit()) {
|
||||
$author_cmd = '';
|
||||
$author = $bundle->getAuthor();
|
||||
if ($author) {
|
||||
$author_cmd = sprintf('-u %s ', $author);
|
||||
}
|
||||
$commit_message = $this->getCommitMessage($bundle);
|
||||
$future = $repository_api->execFutureLocal(
|
||||
'commit -A -l -');
|
||||
'commit -A %C-l -',
|
||||
$author_cmd);
|
||||
$future->write($commit_message);
|
||||
$future->resolvex();
|
||||
$verb = 'committed';
|
||||
|
|
Loading…
Reference in a new issue