1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Parse and display commit authorship date in Git in Diffusion

Summary: Fixes T8826. Git tracks an "author date", which may be different from the "committed date". We don't currently extract/show this; do so.

Test Plan: {F1059235}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8826

Differential Revision: https://secure.phabricator.com/D14995
This commit is contained in:
epriestley 2016-01-11 05:19:13 -08:00
parent 9fb929dff3
commit a061bd2d09
5 changed files with 28 additions and 4 deletions

View file

@ -79,6 +79,7 @@ final class DiffusionQueryCommitsConduitAPIMethod
'repositoryPHID' => $commit->getRepository()->getPHID(),
'identifier' => $commit->getCommitIdentifier(),
'epoch' => $commit->getEpoch(),
'authorEpoch' => $commit_data->getCommitDetail('authorEpoch'),
'uri' => $uri,
'isImporting' => !$commit->isImported(),
'summary' => $commit->getSummary(),
@ -99,6 +100,7 @@ final class DiffusionQueryCommitsConduitAPIMethod
->withIdentifier($commit->getCommitIdentifier())
->execute();
$dict['authorEpoch'] = $lowlevel_commitref->getAuthorEpoch();
$dict['author'] = $lowlevel_commitref->getAuthor();
$dict['authorName'] = $lowlevel_commitref->getAuthorName();
$dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail();

View file

@ -492,8 +492,12 @@ final class DiffusionCommitController extends DiffusionController {
if (!$repository->isSVN()) {
$authored_info = id(new PHUIStatusItemView());
// TODO: In Git, a distinct authorship date is available. When present,
// we should show it here.
$author_epoch = $data->getCommitDetail('authorEpoch');
if ($author_epoch !== null) {
$authored_info->setNote(
phabricator_datetime($author_epoch, $viewer));
}
if ($author_phid) {
$authored_info->setTarget($handles[$author_phid]->renderLink());

View file

@ -3,6 +3,7 @@
final class DiffusionCommitRef extends Phobject {
private $message;
private $authorEpoch;
private $authorName;
private $authorEmail;
private $committerName;
@ -11,6 +12,7 @@ final class DiffusionCommitRef extends Phobject {
public static function newFromConduitResult(array $result) {
$ref = id(new DiffusionCommitRef())
->setAuthorEpoch(idx($result, 'authorEpoch'))
->setCommitterEmail(idx($result, 'committerEmail'))
->setCommitterName(idx($result, 'committerName'))
->setAuthorEmail(idx($result, 'authorEmail'))
@ -38,6 +40,15 @@ final class DiffusionCommitRef extends Phobject {
return $this->hashes;
}
public function setAuthorEpoch($author_epoch) {
$this->authorEpoch = $author_epoch;
return $this;
}
public function getAuthorEpoch() {
return $this->authorEpoch;
}
public function setCommitterEmail($committer_email) {
$this->committerEmail = $committer_email;
return $this;

View file

@ -52,7 +52,7 @@ final class DiffusionLowLevelCommitQuery
'UTF-8',
implode(
'%x00',
array('%e', '%cn', '%ce', '%an', '%ae', '%T', '%s%n%n%b')),
array('%e', '%cn', '%ce', '%an', '%ae', '%T', '%at', '%s%n%n%b')),
$this->identifier);
$parts = explode("\0", $info);
@ -77,13 +77,19 @@ final class DiffusionLowLevelCommitQuery
->setHashValue($parts[4]),
);
$author_epoch = (int)$parts[5];
if (!$author_epoch) {
$author_epoch = null;
}
return id(new DiffusionCommitRef())
->setCommitterName($parts[0])
->setCommitterEmail($parts[1])
->setAuthorName($parts[2])
->setAuthorEmail($parts[3])
->setHashes($hashes)
->setMessage($parts[5]);
->setAuthorEpoch($author_epoch)
->setMessage($parts[6]);
}
private function loadMercurialCommitRef() {

View file

@ -58,6 +58,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
->setMaximumBytes(255)
->truncateString((string)$author));
$data->setCommitDetail('authorEpoch', $ref->getAuthorEpoch());
$data->setCommitDetail('authorName', $ref->getAuthorName());
$data->setCommitDetail('authorEmail', $ref->getAuthorEmail());