mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-01 18:30:59 +01:00
Policy - lock down ReleephCommitFinder
Summary: Not too shabby - just convert some raw queries to the policy queries. Ref T7094. Test Plan: NA 'cuz releeph Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7094 Differential Revision: https://secure.phabricator.com/D11591
This commit is contained in:
parent
388d1ff7bd
commit
0fa31802e7
1 changed files with 11 additions and 6 deletions
|
@ -30,13 +30,16 @@ final class ReleephCommitFinder {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if (preg_match('/^D([1-9]\d*)$/', $partial_string, $matches)) {
|
if (preg_match('/^D([1-9]\d*)$/', $partial_string, $matches)) {
|
||||||
$diff_id = $matches[1];
|
$diff_id = $matches[1];
|
||||||
// TOOD: (T603) This is all slated for annihilation.
|
$diff_rev = id(new DifferentialRevisionQuery())
|
||||||
$diff_rev = id(new DifferentialRevision())->load($diff_id);
|
->setViewer($this->getUser())
|
||||||
|
->withIDs(array($diff_id))
|
||||||
|
->needCommitPHIDs(true)
|
||||||
|
->executeOne();
|
||||||
if (!$diff_rev) {
|
if (!$diff_rev) {
|
||||||
throw new ReleephCommitFinderException(
|
throw new ReleephCommitFinderException(
|
||||||
"{$partial_string} does not refer to an existing diff.");
|
"{$partial_string} does not refer to an existing diff.");
|
||||||
}
|
}
|
||||||
$commit_phids = $diff_rev->loadCommitPHIDs();
|
$commit_phids = $diff_rev->getCommitPHIDs();
|
||||||
|
|
||||||
if (!$commit_phids) {
|
if (!$commit_phids) {
|
||||||
throw new ReleephCommitFinderException(
|
throw new ReleephCommitFinderException(
|
||||||
|
@ -45,9 +48,11 @@ final class ReleephCommitFinder {
|
||||||
|
|
||||||
$this->objectPHID = $diff_rev->getPHID();
|
$this->objectPHID = $diff_rev->getPHID();
|
||||||
|
|
||||||
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
|
$commits = id(new DiffusionCommitQuery())
|
||||||
'phid IN (%Ls) ORDER BY epoch ASC',
|
->setViewer($this->getUser())
|
||||||
$commit_phids);
|
->withPHIDs($commit_phids)
|
||||||
|
->execute();
|
||||||
|
$commits = msort($commits, 'getEpoch');
|
||||||
return head($commits);
|
return head($commits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue