mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 08:42: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 $revisionID;
|
||||||
private $encoding;
|
private $encoding;
|
||||||
private $loadFileDataCallback;
|
private $loadFileDataCallback;
|
||||||
|
private $author;
|
||||||
|
|
||||||
|
public function setAuthor($author) {
|
||||||
|
$this->author = $author;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getAuthor() {
|
||||||
|
return $this->author;
|
||||||
|
}
|
||||||
|
|
||||||
public function setConduit(ConduitClient $conduit) {
|
public function setConduit(ConduitClient $conduit) {
|
||||||
$this->conduit = $conduit;
|
$this->conduit = $conduit;
|
||||||
|
@ -85,6 +94,7 @@ final class ArcanistBundle {
|
||||||
$base_revision = idx($meta_info, 'baseRevision');
|
$base_revision = idx($meta_info, 'baseRevision');
|
||||||
$revision_id = idx($meta_info, 'revisionID');
|
$revision_id = idx($meta_info, 'revisionID');
|
||||||
$encoding = idx($meta_info, 'encoding');
|
$encoding = idx($meta_info, 'encoding');
|
||||||
|
$author = idx($meta_info, 'author');
|
||||||
// this arc bundle was probably made before we started storing meta info
|
// this arc bundle was probably made before we started storing meta info
|
||||||
} else {
|
} else {
|
||||||
$version = 0;
|
$version = 0;
|
||||||
|
@ -92,6 +102,7 @@ final class ArcanistBundle {
|
||||||
$base_revision = null;
|
$base_revision = null;
|
||||||
$revision_id = null;
|
$revision_id = null;
|
||||||
$encoding = null;
|
$encoding = null;
|
||||||
|
$author = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$future = new ExecFuture(
|
$future = new ExecFuture(
|
||||||
|
@ -165,11 +176,12 @@ final class ArcanistBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
$meta_info = array(
|
$meta_info = array(
|
||||||
'version' => 3,
|
'version' => 4,
|
||||||
'projectName' => $this->getProjectID(),
|
'projectName' => $this->getProjectID(),
|
||||||
'baseRevision' => $this->getBaseRevision(),
|
'baseRevision' => $this->getBaseRevision(),
|
||||||
'revisionID' => $this->getRevisionID(),
|
'revisionID' => $this->getRevisionID(),
|
||||||
'encoding' => $this->getEncoding(),
|
'encoding' => $this->getEncoding(),
|
||||||
|
'author' => $this->getAuthor(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$dir = Filesystem::createTemporaryDirectory();
|
$dir = Filesystem::createTemporaryDirectory();
|
||||||
|
|
|
@ -828,6 +828,7 @@ abstract class ArcanistBaseWorkflow {
|
||||||
$bundle->setProjectID($diff['projectName']);
|
$bundle->setProjectID($diff['projectName']);
|
||||||
$bundle->setBaseRevision($diff['sourceControlBaseRevision']);
|
$bundle->setBaseRevision($diff['sourceControlBaseRevision']);
|
||||||
$bundle->setRevisionID($diff['revisionID']);
|
$bundle->setRevisionID($diff['revisionID']);
|
||||||
|
$bundle->setAuthor($diff['author']);
|
||||||
return $bundle;
|
return $bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class ArcanistExportWorkflow extends ArcanistBaseWorkflow {
|
||||||
public function getCommandSynopses() {
|
public function getCommandSynopses() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
**export** [__paths__] __format__ (svn)
|
**export** [__paths__] __format__ (svn)
|
||||||
**export** [__commit_range__] __format__ (git)
|
**export** [__commit_range__] __format__ (git, hg)
|
||||||
**export** __--revision__ __revision_id__ __format__
|
**export** __--revision__ __revision_id__ __format__
|
||||||
**export** __--diff__ __diff_id__ __format__
|
**export** __--diff__ __diff_id__ __format__
|
||||||
EOTEXT
|
EOTEXT
|
||||||
|
@ -35,7 +35,7 @@ EOTEXT
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getCommandHelp() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
Supports: git, svn
|
Supports: svn, git, hg
|
||||||
Export the local changeset (or a Differential changeset) to a file,
|
Export the local changeset (or a Differential changeset) to a file,
|
||||||
in some __format__: git diff (__--git__), unified diff
|
in some __format__: git diff (__--git__), unified diff
|
||||||
(__--unified__), or arc bundle (__--arcbundle__ __path__) format.
|
(__--unified__), or arc bundle (__--arcbundle__ __path__) format.
|
||||||
|
@ -181,12 +181,36 @@ EOTEXT
|
||||||
$this->getArgument('paths'));
|
$this->getArgument('paths'));
|
||||||
$diff = $repository_api->getFullGitDiff();
|
$diff = $repository_api->getFullGitDiff();
|
||||||
$changes = $parser->parseDiff($diff);
|
$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 {
|
} else {
|
||||||
// TODO: paths support
|
// TODO: paths support
|
||||||
$paths = $repository_api->getWorkingCopyStatus();
|
$paths = $repository_api->getWorkingCopyStatus();
|
||||||
$changes = $parser->parseSubversionDiff(
|
$changes = $parser->parseSubversionDiff(
|
||||||
$repository_api,
|
$repository_api,
|
||||||
$paths);
|
$paths);
|
||||||
|
$author = $this->getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
$bundle = ArcanistBundle::newFromChanges($changes);
|
$bundle = ArcanistBundle::newFromChanges($changes);
|
||||||
|
@ -194,6 +218,7 @@ EOTEXT
|
||||||
$bundle->setBaseRevision(
|
$bundle->setBaseRevision(
|
||||||
$repository_api->getSourceControlBaseRevision());
|
$repository_api->getSourceControlBaseRevision());
|
||||||
// note we can't get a revision ID for SOURCE_LOCAL
|
// note we can't get a revision ID for SOURCE_LOCAL
|
||||||
|
$bundle->setAuthor($author);
|
||||||
break;
|
break;
|
||||||
case self::SOURCE_REVISION:
|
case self::SOURCE_REVISION:
|
||||||
$bundle = $this->loadRevisionBundleFromConduit(
|
$bundle = $this->loadRevisionBundleFromConduit(
|
||||||
|
|
|
@ -706,9 +706,24 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->shouldCommit()) {
|
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);
|
$commit_message = $this->getCommitMessage($bundle);
|
||||||
$future = $repository_api->execFutureLocal(
|
$future = $repository_api->execFutureLocal(
|
||||||
'commit -a -F -');
|
'commit -a %C-F -',
|
||||||
|
$author_cmd);
|
||||||
$future->write($commit_message);
|
$future->write($commit_message);
|
||||||
$future->resolvex();
|
$future->resolvex();
|
||||||
$verb = 'committed';
|
$verb = 'committed';
|
||||||
|
@ -758,9 +773,15 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->shouldCommit()) {
|
if ($this->shouldCommit()) {
|
||||||
|
$author_cmd = '';
|
||||||
|
$author = $bundle->getAuthor();
|
||||||
|
if ($author) {
|
||||||
|
$author_cmd = sprintf('-u %s ', $author);
|
||||||
|
}
|
||||||
$commit_message = $this->getCommitMessage($bundle);
|
$commit_message = $this->getCommitMessage($bundle);
|
||||||
$future = $repository_api->execFutureLocal(
|
$future = $repository_api->execFutureLocal(
|
||||||
'commit -A -l -');
|
'commit -A %C-l -',
|
||||||
|
$author_cmd);
|
||||||
$future->write($commit_message);
|
$future->write($commit_message);
|
||||||
$future->resolvex();
|
$future->resolvex();
|
||||||
$verb = 'committed';
|
$verb = 'committed';
|
||||||
|
|
Loading…
Reference in a new issue