private $revisionID;
private $encoding;
private $loadFileDataCallback;
- private $author;
+ private $authorName;
+ private $authorEmail;
- public function setAuthor($author) {
- $this->author = $author;
+ public function setAuthorEmail($author_email) {
+ $this->authorEmail = $author_email;
return $this;
}
- public function getAuthor() {
- return $this->author;
+
+ public function getAuthorEmail() {
+ return $this->authorEmail;
+ }
+
+ public function setAuthorName($author_name) {
+ $this->authorName = $author_name;
+ return $this;
+ }
+
+ public function getAuthorName() {
+ return $this->authorName;
+ }
+
+ public function getFullAuthor() {
+ $author_name = $this->getAuthorName();
+ if ($author_name === null) {
+ return null;
+ }
+
+ $author_email = $this->getAuthorEmail();
+ if ($author_email === null) {
+ return null;
+ }
+
+ $full_author = sprintf('%s <%s>', $author_name, $author_email);
+
+ // Because git is very picky about the author being in a valid format,
+ // verify that we can parse it.
+ $address = new PhutilEmailAddress($full_author);
+ if (!$address->getDisplayName() || !$address->getAddress()) {
+ return null;
+ }
+
+ return $full_author;
}
public function setConduit(ConduitClient $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
+ $author_name = idx($meta_info, 'authorName');
+ $author_email = idx($meta_info, 'authorEmail');
} else {
+ // this arc bundle was probably made before we started storing meta info
$version = 0;
$project_name = null;
$base_revision = null;
}
$meta_info = array(
- 'version' => 4,
+ 'version' => 5,
'projectName' => $this->getProjectID(),
'baseRevision' => $this->getBaseRevision(),
'revisionID' => $this->getRevisionID(),
'encoding' => $this->getEncoding(),
- 'author' => $this->getAuthor(),
+ 'authorName' => $this->getAuthorName(),
+ 'authorEmail' => $this->getAuthorEmail(),
);
$dir = Filesystem::createTemporaryDirectory();
}
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 = csprintf('--author=%s ', $author);
- }
+ if ($bundle->getFullAuthor()) {
+ $author_cmd = csprintf('--author=%s', $bundle->getFullAuthor());
+ } else {
+ $author_cmd = '';
}
+
$commit_message = $this->getCommitMessage($bundle);
$future = $repository_api->execFutureLocal(
- 'commit -a %C-F -',
+ 'commit -a %C -F -',
$author_cmd);
$future->write($commit_message);
$future->resolvex();
}
if ($this->shouldCommit()) {
- $author_cmd = '';
- $author = $bundle->getAuthor();
- if ($author) {
- $author_cmd = sprintf('-u %s ', $author);
+ $author = coalesce($bundle->getFullAuthor(), $bundle->getAuthorName());
+ if ($author !== null) {
+ $author_cmd = csprintf('-u %s', $author);
+ } else {
+ $author_cmd = '';
}
+
$commit_message = $this->getCommitMessage($bundle);
$future = $repository_api->execFutureLocal(
- 'commit -A %C-l -',
+ 'commit -A %C -l -',
$author_cmd);
$future->write($commit_message);
$future->resolvex();