1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Wrap all direct access to author/committer properties on "CommitData"

Summary: Ref T13552. Currently, various callers read raw properties off "CommitData" directly. Wrap these in accessors to support storage changes which persist "CommitRef" information instead.

Test Plan:
- Ran "diffusion.querycommits", saw the same data before and after.
- Looked at a commit, saw authorship information and date.
- Viewed tags in a repository, saw author information.
- Ran "rebuild-identities", saw no net effect.
- Grepped for callers to "getCommitDetail(...)".

Maniphest Tasks: T13552

Differential Revision: https://secure.phabricator.com/D21448
This commit is contained in:
epriestley 2020-08-12 12:34:03 -07:00
parent 7d6874d9f0
commit e454c3dafe
8 changed files with 65 additions and 28 deletions

View file

@ -89,18 +89,18 @@ final class DiffusionQueryCommitsConduitAPIMethod
'repositoryPHID' => $commit->getRepository()->getPHID(),
'identifier' => $commit->getCommitIdentifier(),
'epoch' => $commit->getEpoch(),
'authorEpoch' => $commit_data->getCommitDetail('authorEpoch'),
'authorEpoch' => $commit_data->getAuthorEpoch(),
'uri' => $uri,
'isImporting' => !$commit->isImported(),
'summary' => $commit->getSummary(),
'authorPHID' => $commit->getAuthorPHID(),
'committerPHID' => $commit_data->getCommitDetail('committerPHID'),
'author' => $commit_data->getAuthorName(),
'authorName' => $commit_data->getCommitDetail('authorName'),
'authorEmail' => $commit_data->getCommitDetail('authorEmail'),
'committer' => $commit_data->getCommitDetail('committer'),
'committerName' => $commit_data->getCommitDetail('committerName'),
'committerEmail' => $commit_data->getCommitDetail('committerEmail'),
'author' => $commit_data->getAuthorString(),
'authorName' => $commit_data->getAuthorDisplayName(),
'authorEmail' => $commit_data->getAuthorEmail(),
'committer' => $commit_data->getCommitterString(),
'committerName' => $commit_data->getCommitterDisplayName(),
'committerEmail' => $commit_data->getCommitterEmail(),
'hashes' => array(),
);

View file

@ -626,7 +626,7 @@ final class DiffusionCommitController extends DiffusionController {
$author_view = $commit->newCommitAuthorView($viewer);
if ($author_view) {
$author_date = $data->getCommitDetail('authorEpoch');
$author_date = $data->getAuthorEpoch();
$author_date = phabricator_datetime($author_date, $viewer);
$provenance_list->addItem(

View file

@ -104,7 +104,7 @@ final class DiffusionPathChange extends Phobject {
public function getAuthorName() {
if ($this->getCommitData()) {
return $this->getCommitData()->getAuthorName();
return $this->getCommitData()->getAuthorString();
}
return null;
}

View file

@ -150,7 +150,7 @@ final class DiffusionTagListView extends DiffusionView {
if ($commit->getAuthorPHID()) {
$author = $this->handles[$commit->getAuthorPHID()]->renderLink();
} else if ($commit->getCommitData()) {
$author = self::renderName($commit->getCommitData()->getAuthorName());
$author = self::renderName($commit->getCommitData()->getAuthorString());
} else {
$author = self::renderName($tag->getAuthor());
}

View file

@ -202,11 +202,11 @@ final class PhabricatorRepositoryManagementRebuildIdentitiesWorkflow
$needs_update = false;
$data = $commit->getCommitData();
$author_name = $data->getAuthorName();
$author = $data->getAuthorString();
$author_identity = $this->getIdentityForCommit(
$commit,
$author_name);
$author);
$author_phid = $commit->getAuthorIdentityPHID();
$identity_phid = $author_identity->getPHID();
@ -218,7 +218,7 @@ final class PhabricatorRepositoryManagementRebuildIdentitiesWorkflow
$needs_update = true;
}
$committer_name = $data->getCommitDetail('committer', null);
$committer_name = $data->getCommitterString();
$committer_phid = $commit->getCommitterIdentityPHID();
if (strlen($committer_name)) {
$committer_identity = $this->getIdentityForCommit(

View file

@ -515,12 +515,12 @@ final class PhabricatorRepositoryCommit
private function getRawAuthorStringForDisplay() {
$data = $this->getCommitData();
return $data->getAuthorName();
return $data->getAuthorString();
}
private function getRawCommitterStringForDisplay() {
$data = $this->getCommitData();
return $data->getCommitDetail('committer');
return $data->getCommitterString();
}
public function newCommitRef(PhabricatorUser $viewer) {
@ -898,12 +898,7 @@ final class PhabricatorRepositoryCommit
$committer_user_phid = null;
}
$author_epoch = $data->getCommitDetail('authorEpoch');
if ($author_epoch) {
$author_epoch = (int)$author_epoch;
} else {
$author_epoch = null;
}
$author_epoch = $data->getAuthorEpoch();
$audit_status = $this->getAuditStatusObject();

View file

@ -92,13 +92,55 @@ final class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO {
return array_values($holds);
}
public function setCommitRef(DiffusionCommitRef $ref) {
$this->setCommitDetail('commitRef', $ref->newDictionary());
public function getAuthorString() {
$author = phutil_string_cast($this->authorName);
if (strlen($author)) {
return $author;
}
public function newCommitRef() {
$map = $this->getCommitDetail('commitRef', array());
return DiffusionCommitRef::neWFromDictionary($map);
return null;
}
public function getAuthorDisplayName() {
return $this->getCommitDetailString('authorName');
}
public function getAuthorEmail() {
return $this->getCommitDetailString('authorEmail');
}
public function getAuthorEpoch() {
$epoch = $this->getCommitDetail('authorEpoch');
if ($epoch) {
return (int)$epoch;
}
return null;
}
public function getCommitterString() {
return $this->getCommitDetailString('committer');
}
public function getCommitterDisplayName() {
return $this->getCommitDetailString('committerName');
}
public function getCommitterEmail() {
return $this->getCommitDetailString('committerEmail');
}
private function getCommitDetailString($key) {
$string = $this->getCommitDetail($key);
$string = phutil_string_cast($string);
if (strlen($string)) {
return $string;
}
return null;
}
}

View file

@ -116,9 +116,9 @@ final class PhabricatorRepositoryCommitPublishWorker
array(
'description' => $data->getCommitMessage(),
'summary' => $data->getSummary(),
'authorName' => $data->getAuthorName(),
'authorName' => $data->getAuthorString(),
'authorPHID' => $commit->getAuthorPHID(),
'committerName' => $data->getCommitDetail('committer'),
'committerName' => $data->getCommitterString(),
'committerPHID' => $data->getCommitDetail('committerPHID'),
));