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;
$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;
$base_revision = null;
$revision_id = null;
$encoding = null;
+ $author = null;
}
$future = new ExecFuture(
}
$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();
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
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.
$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);
$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(
}
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';
}
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';