mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-08 12:58:31 +01:00
Start changing DiffusionCommitController to use identities
Summary: Depends on D19491. Test Plan: Viewed some commits where the identity was mapped to a user and another that wasn't; saw the header render either a link to the user or the identity object. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D19492
This commit is contained in:
parent
9a15129b40
commit
3b05e920e0
3 changed files with 87 additions and 24 deletions
|
@ -46,6 +46,7 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
->needCommitData(true)
|
->needCommitData(true)
|
||||||
->needAuditRequests(true)
|
->needAuditRequests(true)
|
||||||
->setLimit(100)
|
->setLimit(100)
|
||||||
|
->needIdentities(true)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$multiple_results = count($commits) > 1;
|
$multiple_results = count($commits) > 1;
|
||||||
|
@ -504,15 +505,13 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
|
|
||||||
$phids = $edge_query->getDestinationPHIDs(array($commit_phid));
|
$phids = $edge_query->getDestinationPHIDs(array($commit_phid));
|
||||||
|
|
||||||
if ($data->getCommitDetail('authorPHID')) {
|
|
||||||
$phids[] = $data->getCommitDetail('authorPHID');
|
|
||||||
}
|
|
||||||
if ($data->getCommitDetail('reviewerPHID')) {
|
if ($data->getCommitDetail('reviewerPHID')) {
|
||||||
$phids[] = $data->getCommitDetail('reviewerPHID');
|
$phids[] = $data->getCommitDetail('reviewerPHID');
|
||||||
}
|
}
|
||||||
if ($data->getCommitDetail('committerPHID')) {
|
|
||||||
$phids[] = $data->getCommitDetail('committerPHID');
|
$phids[] = $commit->getCommitterDisplayPHID();
|
||||||
}
|
$phids[] = $commit->getAuthorDisplayPHID();
|
||||||
|
|
||||||
// NOTE: We should never normally have more than a single push log, but
|
// NOTE: We should never normally have more than a single push log, but
|
||||||
// it can occur naturally if a commit is pushed, then the branch it was
|
// it can occur naturally if a commit is pushed, then the branch it was
|
||||||
|
@ -573,24 +572,11 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$author_phid = $data->getCommitDetail('authorPHID');
|
|
||||||
$author_name = $data->getAuthorName();
|
|
||||||
$author_epoch = $data->getCommitDetail('authorEpoch');
|
$author_epoch = $data->getCommitDetail('authorEpoch');
|
||||||
|
|
||||||
$committed_info = id(new PHUIStatusItemView())
|
$committed_info = id(new PHUIStatusItemView())
|
||||||
->setNote(phabricator_datetime($commit->getEpoch(), $viewer));
|
->setNote(phabricator_datetime($commit->getEpoch(), $viewer))
|
||||||
|
->setTarget($commit->renderAnyCommitter($viewer, $handles));
|
||||||
$committer_phid = $data->getCommitDetail('committerPHID');
|
|
||||||
$committer_name = $data->getCommitDetail('committer');
|
|
||||||
if ($committer_phid) {
|
|
||||||
$committed_info->setTarget($handles[$committer_phid]->renderLink());
|
|
||||||
} else if (strlen($committer_name)) {
|
|
||||||
$committed_info->setTarget($committer_name);
|
|
||||||
} else if ($author_phid) {
|
|
||||||
$committed_info->setTarget($handles[$author_phid]->renderLink());
|
|
||||||
} else if (strlen($author_name)) {
|
|
||||||
$committed_info->setTarget($author_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$committed_list = new PHUIStatusListView();
|
$committed_list = new PHUIStatusListView();
|
||||||
$committed_list->addItem($committed_info);
|
$committed_list->addItem($committed_info);
|
||||||
|
@ -716,7 +702,7 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$author_phid = $data->getCommitDetail('authorPHID');
|
$author_phid = $commit->getAuthorDisplayPHID();
|
||||||
$author_name = $data->getAuthorName();
|
$author_name = $data->getAuthorName();
|
||||||
$author_epoch = $data->getCommitDetail('authorEpoch');
|
$author_epoch = $data->getCommitDetail('authorEpoch');
|
||||||
$date = null;
|
$date = null;
|
||||||
|
@ -748,10 +734,8 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
->setImage($image_uri)
|
->setImage($image_uri)
|
||||||
->setImageHref($image_href)
|
->setImageHref($image_href)
|
||||||
->setContent($content);
|
->setContent($content);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function buildComments(PhabricatorRepositoryCommit $commit) {
|
private function buildComments(PhabricatorRepositoryCommit $commit) {
|
||||||
$timeline = $this->buildTransactionTimeline(
|
$timeline = $this->buildTransactionTimeline(
|
||||||
$commit,
|
$commit,
|
||||||
|
|
|
@ -439,6 +439,77 @@ final class PhabricatorRepositoryCommit
|
||||||
return $repository->formatCommitName($identifier, $local = true);
|
return $repository->formatCommitName($identifier, $local = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a strong effort to find a way to render this commit's committer.
|
||||||
|
* This currently attempts to use @{PhabricatorRepositoryIdentity}, and
|
||||||
|
* falls back to examining the commit detail information. After we force
|
||||||
|
* the migration to using identities, update this method to remove the
|
||||||
|
* fallback. See T12164 for details.
|
||||||
|
*/
|
||||||
|
public function renderAnyCommitter(PhabricatorUser $viewer, array $handles) {
|
||||||
|
$committer = $this->renderCommitter($viewer, $handles);
|
||||||
|
if ($committer) {
|
||||||
|
return $committer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->renderAuthor($viewer, $handles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderCommitter(PhabricatorUser $viewer, array $handles) {
|
||||||
|
$committer_phid = $this->getCommitterDisplayPHID();
|
||||||
|
if ($committer_phid) {
|
||||||
|
return $handles[$committer_phid]->renderLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->getCommitData();
|
||||||
|
$committer_name = $data->getCommitDetail('committer');
|
||||||
|
if (strlen($committer_name)) {
|
||||||
|
return $committer_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderAuthor(PhabricatorUser $viewer, array $handles) {
|
||||||
|
$author_phid = $this->getAuthorDisplayPHID();
|
||||||
|
if ($author_phid) {
|
||||||
|
return $handles[$author_phid]->renderLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->getCommitData();
|
||||||
|
$author_name = $data->getAuthorName();
|
||||||
|
if (strlen($author_name)) {
|
||||||
|
return $author_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasCommitterIdentity() {
|
||||||
|
return ($this->getCommitterIdentity() !== null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasAuthorIdentity() {
|
||||||
|
return ($this->getAuthorIdentity() !== null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCommitterDisplayPHID() {
|
||||||
|
if ($this->hasCommitterIdentity()) {
|
||||||
|
return $this->getCommitterIdentity()->getIdentityDisplayPHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->getCommitData();
|
||||||
|
return $data->getCommitDetail('committerPHID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAuthorDisplayPHID() {
|
||||||
|
if ($this->hasAuthorIdentity()) {
|
||||||
|
return $this->getAuthorIdentity()->getIdentityDisplayPHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->getCommitData();
|
||||||
|
return $data->getCommitDetail('authorPHID');
|
||||||
|
}
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,14 @@ final class PhabricatorRepositoryIdentity
|
||||||
return ($this->currentEffectiveUserPHID != null);
|
return ($this->currentEffectiveUserPHID != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIdentityDisplayPHID() {
|
||||||
|
if ($this->hasEffectiveUser()) {
|
||||||
|
return $this->getCurrentEffectiveUserPHID();
|
||||||
|
} else {
|
||||||
|
return $this->getPHID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
if ($this->manuallySetUserPHID) {
|
if ($this->manuallySetUserPHID) {
|
||||||
$this->currentEffectiveUserPHID = $this->manuallySetUserPHID;
|
$this->currentEffectiveUserPHID = $this->manuallySetUserPHID;
|
||||||
|
|
Loading…
Add table
Reference in a new issue