Path: blob/master/src/applications/differential/controller/DifferentialRevisionCloseDetailsController.php
12262 views
<?php12final class DifferentialRevisionCloseDetailsController3extends DifferentialController {45public function handleRequest(AphrontRequest $request) {6$viewer = $this->getViewer();78$xaction = id(new PhabricatorObjectQuery())9->withPHIDs(array($request->getURIData('phid')))10->setViewer($viewer)11->executeOne();12if (!$xaction) {13return new Aphront404Response();14}1516$obj_phid = $xaction->getObjectPHID();17$obj_handle = id(new PhabricatorHandleQuery())18->setViewer($viewer)19->withPHIDs(array($obj_phid))20->executeOne();2122$body = $this->getRevisionMatchExplanation(23$xaction->getMetadataValue('revisionMatchData'),24$obj_handle);2526$dialog = id(new AphrontDialogView())27->setUser($viewer)28->setTitle(pht('Commit Close Explanation'))29->appendParagraph($body)30->addCancelButton($obj_handle->getURI());3132return id(new AphrontDialogResponse())->setDialog($dialog);33}3435private function getRevisionMatchExplanation(36$revision_match_data,37PhabricatorObjectHandle $obj_handle) {3839if (!$revision_match_data) {40return pht(41'This commit was made before this feature was built and thus this '.42'information is unavailable.');43}4445$body_why = array();46if ($revision_match_data['usedURI']) {47return pht(48'We found a "%s" field with value "%s" in the commit message, '.49'and the domain on the URI matches this install, so '.50'we linked this commit to %s.',51'Differential Revision',52$revision_match_data['foundURI'],53phutil_tag(54'a',55array(56'href' => $obj_handle->getURI(),57),58$obj_handle->getName()));59} else if ($revision_match_data['foundURI']) {60$body_why[] = pht(61'We found a "%s" field with value "%s" in the commit message, '.62'but the domain on this URI did not match the configured '.63'domain for this install, "%s", so we ignored it under '.64'the assumption that it refers to some third-party revision.',65'Differential Revision',66$revision_match_data['foundURI'],67$revision_match_data['validDomain']);68} else {69$body_why[] = pht(70'We didn\'t find a "%s" field in the commit message.',71'Differential Revision');72}7374switch ($revision_match_data['matchHashType']) {75case ArcanistDifferentialRevisionHash::HASH_GIT_TREE:76$hash_info = true;77$hash_type = 'tree';78break;79case ArcanistDifferentialRevisionHash::HASH_GIT_COMMIT:80case ArcanistDifferentialRevisionHash::HASH_MERCURIAL_COMMIT:81$hash_info = true;82$hash_type = 'commit';83break;84default:85$hash_info = false;86break;87}88if ($hash_info) {89$diff_link = phutil_tag(90'a',91array(92'href' => $obj_handle->getURI(),93),94$obj_handle->getName());95$body_why[] = pht(96'This commit and the active diff of %s had the same %s hash '.97'(%s) so we linked this commit to %s.',98$diff_link,99$hash_type,100$revision_match_data['matchHashValue'],101$diff_link);102}103104return phutil_implode_html("\n", $body_why);105106}107}108109110