private function getRevisionMatchExplanation($revision_match_data, PhabricatorObjectHandle $obj_handle) { if (!$revision_match_data) { return pht('This commit was made before this feature was built and thus this ' . 'information is unavailable.'); } $body_why = array(); if ($revision_match_data['usedURI']) { return pht('We found a "%s" field with value "%s" in the commit message, ' . 'and the domain on the URI matches this install, so ' . 'we linked this commit to %s.', 'Differential Revision', $revision_match_data['foundURI'], phutil_tag('a', array('href' => $obj_handle->getURI()), $obj_handle->getName())); } else { if ($revision_match_data['foundURI']) { $body_why[] = pht('We found a "%s" field with value "%s" in the commit message, ' . 'but the domain on this URI did not match the configured ' . 'domain for this install, "%s", so we ignored it under ' . 'the assumption that it refers to some third-party revision.', 'Differential Revision', $revision_match_data['foundURI'], $revision_match_data['validDomain']); } else { $body_why[] = pht('We didn\'t find a "%s" field in the commit message.', 'Differential Revision'); } } switch ($revision_match_data['matchHashType']) { case ArcanistDifferentialRevisionHash::HASH_GIT_TREE: $hash_info = true; $hash_type = 'tree'; break; case ArcanistDifferentialRevisionHash::HASH_GIT_COMMIT: case ArcanistDifferentialRevisionHash::HASH_MERCURIAL_COMMIT: $hash_info = true; $hash_type = 'commit'; break; default: $hash_info = false; break; } if ($hash_info) { $diff_link = phutil_tag('a', array('href' => $obj_handle->getURI()), $obj_handle->getName()); $body_why = pht('This commit and the active diff of %s had the same %s hash ' . '(%s) so we linked this commit to %s.', $diff_link, $hash_type, $revision_match_data['matchHashValue'], $diff_link); } return phutil_implode_html("\n", $body_why); }
private function renderHandleIcon(PhabricatorObjectHandle $handle) { $ownername = $handle->getName(); $ownerlink = '/p/' . $ownername . '/'; $image_uri = 'background-image: url(' . $handle->getImageURI() . ')'; $sigil = 'has-tooltip'; $meta = array('tip' => pht($ownername), 'size' => 200, 'align' => 'E'); $image = id(new SprintHandleIconView())->addSigil($sigil)->setMetadata($meta)->setHref($ownerlink)->setIconStyle($image_uri); return $image; }
protected function getObjectNameText($object, PhabricatorObjectHandle $handle, $id) { // If this commit is unreachable, return the handle name instead of the // normal text because it may be able to tell the user that the commit // was rewritten and where to find the new one. // By default, we try to preserve what the user actually typed as // faithfully as possible, but if they're referencing a deleted commit // it's more valuable to try to pick up any rewrite. See T11522. if ($object->isUnreachable()) { return $handle->getName(); } return parent::getObjectNameText($object, $handle, $id); }
public function renderHovercard(PhabricatorHovercardView $hovercard, PhabricatorObjectHandle $handle, $commit, $data) { $viewer = $this->getViewer(); $author_phid = $commit->getAuthorPHID(); if ($author_phid) { $author = $viewer->renderHandle($author_phid); } else { $commit_data = $commit->loadCommitData(); $author = phutil_tag('em', array(), $commit_data->getAuthorName()); } $hovercard->setTitle($handle->getName()); $hovercard->setDetail($commit->getSummary()); $hovercard->addField(pht('Author'), $author); $hovercard->addField(pht('Date'), phabricator_date($commit->getEpoch(), $viewer)); if ($commit->getAuditStatus() != PhabricatorAuditCommitStatusConstants::NONE) { $hovercard->addField(pht('Audit Status'), PhabricatorAuditCommitStatusConstants::getStatusName($commit->getAuditStatus())); } }
public static function newFromPolicyAndHandle($policy_identifier, PhabricatorObjectHandle $handle = null) { $is_global = PhabricatorPolicyQuery::isGlobalPolicy($policy_identifier); if ($is_global) { return PhabricatorPolicyQuery::getGlobalPolicy($policy_identifier); } $policy = PhabricatorPolicyQuery::getObjectPolicy($policy_identifier); if ($policy) { return $policy; } if (!$handle) { throw new Exception(pht("Policy identifier is an object PHID ('%s'), but no object handle " . "was provided. A handle must be provided for object policies.", $policy_identifier)); } $handle_phid = $handle->getPHID(); if ($policy_identifier != $handle_phid) { throw new Exception(pht("Policy identifier is an object PHID ('%s'), but the provided " . "handle has a different PHID ('%s'). The handle must correspond " . "to the policy identifier.", $policy_identifier, $handle_phid)); } $policy = id(new PhabricatorPolicy())->setPHID($policy_identifier)->setHref($handle->getURI()); $phid_type = phid_get_type($policy_identifier); switch ($phid_type) { case PhabricatorProjectProjectPHIDType::TYPECONST: $policy->setType(PhabricatorPolicyType::TYPE_PROJECT); $policy->setName($handle->getName()); break; case PhabricatorPeopleUserPHIDType::TYPECONST: $policy->setType(PhabricatorPolicyType::TYPE_USER); $policy->setName($handle->getFullName()); break; case PhabricatorPolicyPHIDTypePolicy::TYPECONST: // TODO: This creates a weird handle-based version of a rule policy. // It behaves correctly, but can't be applied since it doesn't have // any rules. It is used to render transactions, and might need some // cleanup. break; default: $policy->setType(PhabricatorPolicyType::TYPE_MASKED); $policy->setName($handle->getFullName()); break; } $policy->makeEphemeral(); return $policy; }
private function buildCommitView(PhabricatorObjectHandle $handle = null) { $request = $this->getRequest(); $query = new PhabricatorAuditCommitQuery(); $query->needCommitData(true); $use_pager = $this->filter != 'active'; if ($use_pager) { $pager = new AphrontPagerView(); $pager->setURI($request->getRequestURI(), 'offset'); $pager->setOffset($request->getInt('offset')); $query->setOffset($pager->getOffset()); $query->setLimit($pager->getPageSize() + 1); } switch ($this->filter) { case 'active': case 'author': $query->withAuthorPHIDs(array($handle->getPHID())); break; case 'packagecommits': $query->withPackagePHIDs(array($handle->getPHID())); break; } switch ($this->filter) { case 'active': $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN); break; case 'author': case 'packagecommits': switch ($this->filterStatus) { case 'open': $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN); break; } break; } if ($handle) { $handle_name = phutil_escape_html($handle->getName()); } else { $handle_name = null; } switch ($this->filter) { case 'active': $header = 'Problem Commits'; $nodata = 'None of your commits have open concerns.'; break; case 'author': $header = "Commits by {$handle_name}"; $nodata = "No matching commits by {$handle_name}."; break; case 'commits': $header = "Commits"; $nodata = "No matching commits."; break; case 'packagecommits': $header = "Commits in Package '{$handle_name}'"; $nodata = "No matching commits in package '{$handle_name}'."; break; } $commits = $query->execute(); if ($use_pager) { $commits = $pager->sliceResults($commits); } $view = new PhabricatorAuditCommitListView(); $view->setUser($request->getUser()); $view->setCommits($commits); $view->setNoDataString($nodata); $phids = $view->getRequiredHandlePHIDs(); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $view->setHandles($handles); $panel = new AphrontPanelView(); $panel->setHeader($header); $panel->appendChild($view); if ($use_pager) { $panel->appendChild($pager); } return $panel; }
protected function buildHandleInformationDictionary(PhabricatorObjectHandle $handle) { return array('phid' => $handle->getPHID(), 'uri' => PhabricatorEnv::getProductionURI($handle->getURI()), 'typeName' => $handle->getTypeName(), 'type' => $handle->getType(), 'name' => $handle->getName(), 'fullName' => $handle->getFullName(), 'status' => $handle->getStatus()); }