Differential D20418 Diff 48760 src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (!PhabricatorEnv::getEnvConfig($config_key)) { | ||||
'author. You can only close revisions you own. You can change '. | 'author. You can only close revisions you own. You can change '. | ||||
'this behavior by adjusting the "%s" setting in Config.', | 'this behavior by adjusting the "%s" setting in Config.', | ||||
$config_key)); | $config_key)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public function getTitle() { | public function getTitle() { | ||||
if (!$this->getMetadataValue('isCommitClose')) { | |||||
return pht( | |||||
'%s closed this revision.', | |||||
$this->renderAuthor()); | |||||
} | |||||
$commit_phid = $this->getMetadataValue('commitPHID'); | $commit_phid = $this->getMetadataValue('commitPHID'); | ||||
$committer_phid = $this->getMetadataValue('committerPHID'); | if ($commit_phid) { | ||||
$author_phid = $this->getMetadataValue('authorPHID'); | $commit = id(new DiffusionCommitQuery()) | ||||
->setViewer($this->getViewer()) | |||||
if ($committer_phid) { | ->withPHIDs(array($commit_phid)) | ||||
$committer_name = $this->renderHandle($committer_phid); | ->needIdentities(true) | ||||
->executeOne(); | |||||
} else { | } else { | ||||
$committer_name = $this->getMetadataValue('committerName'); | $commit = null; | ||||
} | } | ||||
if ($author_phid) { | if (!$commit) { | ||||
$author_name = $this->renderHandle($author_phid); | return pht( | ||||
} else { | '%s closed this revision.', | ||||
$author_name = $this->getMetadatavalue('authorName'); | $this->renderAuthor()); | ||||
} | } | ||||
$same_phid = | $author_phid = $commit->getAuthorDisplayPHID(); | ||||
strlen($committer_phid) && | $committer_phid = $commit->getCommitterDisplayPHID(); | ||||
strlen($author_phid) && | |||||
($committer_phid == $author_phid); | |||||
$same_name = | |||||
!strlen($committer_phid) && | |||||
!strlen($author_phid) && | |||||
($committer_name == $author_name); | |||||
if ($same_name || $same_phid) { | if (!$author_phid) { | ||||
return pht( | |||||
'Closed by commit %s.', | |||||
$this->renderHandle($commit_phid)); | |||||
} else if (!$committer_phid || ($committer_phid === $author_phid)) { | |||||
return pht( | return pht( | ||||
'Closed by commit %s (authored by %s).', | 'Closed by commit %s (authored by %s).', | ||||
$this->renderHandle($commit_phid), | $this->renderHandle($commit_phid), | ||||
$author_name); | $this->renderHandle($author_phid)); | ||||
} else { | } else { | ||||
return pht( | return pht( | ||||
'Closed by commit %s (authored by %s, committed by %s).', | 'Closed by commit %s (authored by %s, committed by %s).', | ||||
$this->renderHandle($commit_phid), | $this->renderHandle($commit_phid), | ||||
$author_name, | $this->renderHandle($author_phid), | ||||
$committer_name); | $this->renderHandle($committer_phid)); | ||||
} | } | ||||
} | } | ||||
public function getTitleForFeed() { | public function getTitleForFeed() { | ||||
return pht( | return pht( | ||||
'%s closed %s.', | '%s closed %s.', | ||||
$this->renderAuthor(), | $this->renderAuthor(), | ||||
$this->renderObject()); | $this->renderObject()); | ||||
Show All 21 Lines |