mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +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:
parent
7d6874d9f0
commit
e454c3dafe
8 changed files with 65 additions and 28 deletions
|
@ -89,18 +89,18 @@ final class DiffusionQueryCommitsConduitAPIMethod
|
||||||
'repositoryPHID' => $commit->getRepository()->getPHID(),
|
'repositoryPHID' => $commit->getRepository()->getPHID(),
|
||||||
'identifier' => $commit->getCommitIdentifier(),
|
'identifier' => $commit->getCommitIdentifier(),
|
||||||
'epoch' => $commit->getEpoch(),
|
'epoch' => $commit->getEpoch(),
|
||||||
'authorEpoch' => $commit_data->getCommitDetail('authorEpoch'),
|
'authorEpoch' => $commit_data->getAuthorEpoch(),
|
||||||
'uri' => $uri,
|
'uri' => $uri,
|
||||||
'isImporting' => !$commit->isImported(),
|
'isImporting' => !$commit->isImported(),
|
||||||
'summary' => $commit->getSummary(),
|
'summary' => $commit->getSummary(),
|
||||||
'authorPHID' => $commit->getAuthorPHID(),
|
'authorPHID' => $commit->getAuthorPHID(),
|
||||||
'committerPHID' => $commit_data->getCommitDetail('committerPHID'),
|
'committerPHID' => $commit_data->getCommitDetail('committerPHID'),
|
||||||
'author' => $commit_data->getAuthorName(),
|
'author' => $commit_data->getAuthorString(),
|
||||||
'authorName' => $commit_data->getCommitDetail('authorName'),
|
'authorName' => $commit_data->getAuthorDisplayName(),
|
||||||
'authorEmail' => $commit_data->getCommitDetail('authorEmail'),
|
'authorEmail' => $commit_data->getAuthorEmail(),
|
||||||
'committer' => $commit_data->getCommitDetail('committer'),
|
'committer' => $commit_data->getCommitterString(),
|
||||||
'committerName' => $commit_data->getCommitDetail('committerName'),
|
'committerName' => $commit_data->getCommitterDisplayName(),
|
||||||
'committerEmail' => $commit_data->getCommitDetail('committerEmail'),
|
'committerEmail' => $commit_data->getCommitterEmail(),
|
||||||
'hashes' => array(),
|
'hashes' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -626,7 +626,7 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
|
|
||||||
$author_view = $commit->newCommitAuthorView($viewer);
|
$author_view = $commit->newCommitAuthorView($viewer);
|
||||||
if ($author_view) {
|
if ($author_view) {
|
||||||
$author_date = $data->getCommitDetail('authorEpoch');
|
$author_date = $data->getAuthorEpoch();
|
||||||
$author_date = phabricator_datetime($author_date, $viewer);
|
$author_date = phabricator_datetime($author_date, $viewer);
|
||||||
|
|
||||||
$provenance_list->addItem(
|
$provenance_list->addItem(
|
||||||
|
|
|
@ -104,7 +104,7 @@ final class DiffusionPathChange extends Phobject {
|
||||||
|
|
||||||
public function getAuthorName() {
|
public function getAuthorName() {
|
||||||
if ($this->getCommitData()) {
|
if ($this->getCommitData()) {
|
||||||
return $this->getCommitData()->getAuthorName();
|
return $this->getCommitData()->getAuthorString();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ final class DiffusionTagListView extends DiffusionView {
|
||||||
if ($commit->getAuthorPHID()) {
|
if ($commit->getAuthorPHID()) {
|
||||||
$author = $this->handles[$commit->getAuthorPHID()]->renderLink();
|
$author = $this->handles[$commit->getAuthorPHID()]->renderLink();
|
||||||
} else if ($commit->getCommitData()) {
|
} else if ($commit->getCommitData()) {
|
||||||
$author = self::renderName($commit->getCommitData()->getAuthorName());
|
$author = self::renderName($commit->getCommitData()->getAuthorString());
|
||||||
} else {
|
} else {
|
||||||
$author = self::renderName($tag->getAuthor());
|
$author = self::renderName($tag->getAuthor());
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,11 +202,11 @@ final class PhabricatorRepositoryManagementRebuildIdentitiesWorkflow
|
||||||
$needs_update = false;
|
$needs_update = false;
|
||||||
|
|
||||||
$data = $commit->getCommitData();
|
$data = $commit->getCommitData();
|
||||||
$author_name = $data->getAuthorName();
|
$author = $data->getAuthorString();
|
||||||
|
|
||||||
$author_identity = $this->getIdentityForCommit(
|
$author_identity = $this->getIdentityForCommit(
|
||||||
$commit,
|
$commit,
|
||||||
$author_name);
|
$author);
|
||||||
|
|
||||||
$author_phid = $commit->getAuthorIdentityPHID();
|
$author_phid = $commit->getAuthorIdentityPHID();
|
||||||
$identity_phid = $author_identity->getPHID();
|
$identity_phid = $author_identity->getPHID();
|
||||||
|
@ -218,7 +218,7 @@ final class PhabricatorRepositoryManagementRebuildIdentitiesWorkflow
|
||||||
$needs_update = true;
|
$needs_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$committer_name = $data->getCommitDetail('committer', null);
|
$committer_name = $data->getCommitterString();
|
||||||
$committer_phid = $commit->getCommitterIdentityPHID();
|
$committer_phid = $commit->getCommitterIdentityPHID();
|
||||||
if (strlen($committer_name)) {
|
if (strlen($committer_name)) {
|
||||||
$committer_identity = $this->getIdentityForCommit(
|
$committer_identity = $this->getIdentityForCommit(
|
||||||
|
|
|
@ -515,12 +515,12 @@ final class PhabricatorRepositoryCommit
|
||||||
|
|
||||||
private function getRawAuthorStringForDisplay() {
|
private function getRawAuthorStringForDisplay() {
|
||||||
$data = $this->getCommitData();
|
$data = $this->getCommitData();
|
||||||
return $data->getAuthorName();
|
return $data->getAuthorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRawCommitterStringForDisplay() {
|
private function getRawCommitterStringForDisplay() {
|
||||||
$data = $this->getCommitData();
|
$data = $this->getCommitData();
|
||||||
return $data->getCommitDetail('committer');
|
return $data->getCommitterString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newCommitRef(PhabricatorUser $viewer) {
|
public function newCommitRef(PhabricatorUser $viewer) {
|
||||||
|
@ -898,12 +898,7 @@ final class PhabricatorRepositoryCommit
|
||||||
$committer_user_phid = null;
|
$committer_user_phid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$author_epoch = $data->getCommitDetail('authorEpoch');
|
$author_epoch = $data->getAuthorEpoch();
|
||||||
if ($author_epoch) {
|
|
||||||
$author_epoch = (int)$author_epoch;
|
|
||||||
} else {
|
|
||||||
$author_epoch = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$audit_status = $this->getAuditStatusObject();
|
$audit_status = $this->getAuditStatusObject();
|
||||||
|
|
||||||
|
|
|
@ -92,13 +92,55 @@ final class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO {
|
||||||
return array_values($holds);
|
return array_values($holds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCommitRef(DiffusionCommitRef $ref) {
|
public function getAuthorString() {
|
||||||
$this->setCommitDetail('commitRef', $ref->newDictionary());
|
$author = phutil_string_cast($this->authorName);
|
||||||
|
|
||||||
|
if (strlen($author)) {
|
||||||
|
return $author;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newCommitRef() {
|
public function getAuthorDisplayName() {
|
||||||
$map = $this->getCommitDetail('commitRef', array());
|
return $this->getCommitDetailString('authorName');
|
||||||
return DiffusionCommitRef::neWFromDictionary($map);
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,9 +116,9 @@ final class PhabricatorRepositoryCommitPublishWorker
|
||||||
array(
|
array(
|
||||||
'description' => $data->getCommitMessage(),
|
'description' => $data->getCommitMessage(),
|
||||||
'summary' => $data->getSummary(),
|
'summary' => $data->getSummary(),
|
||||||
'authorName' => $data->getAuthorName(),
|
'authorName' => $data->getAuthorString(),
|
||||||
'authorPHID' => $commit->getAuthorPHID(),
|
'authorPHID' => $commit->getAuthorPHID(),
|
||||||
'committerName' => $data->getCommitDetail('committer'),
|
'committerName' => $data->getCommitterString(),
|
||||||
'committerPHID' => $data->getCommitDetail('committerPHID'),
|
'committerPHID' => $data->getCommitDetail('committerPHID'),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue