mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +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();
|
||||
if (preg_match('/^D([1-9]\d*)$/', $partial_string, $matches)) {
|
||||
$diff_id = $matches[1];
|
||||
// TOOD: (T603) This is all slated for annihilation.
|
||||
$diff_rev = id(new DifferentialRevision())->load($diff_id);
|
||||
$diff_rev = id(new DifferentialRevisionQuery())
|
||||
->setViewer($this->getUser())
|
||||
->withIDs(array($diff_id))
|
||||
->needCommitPHIDs(true)
|
||||
->executeOne();
|
||||
if (!$diff_rev) {
|
||||
throw new ReleephCommitFinderException(
|
||||
"{$partial_string} does not refer to an existing diff.");
|
||||
}
|
||||
$commit_phids = $diff_rev->loadCommitPHIDs();
|
||||
$commit_phids = $diff_rev->getCommitPHIDs();
|
||||
|
||||
if (!$commit_phids) {
|
||||
throw new ReleephCommitFinderException(
|
||||
|
@ -45,9 +48,11 @@ final class ReleephCommitFinder {
|
|||
|
||||
$this->objectPHID = $diff_rev->getPHID();
|
||||
|
||||
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
|
||||
'phid IN (%Ls) ORDER BY epoch ASC',
|
||||
$commit_phids);
|
||||
$commits = id(new DiffusionCommitQuery())
|
||||
->setViewer($this->getUser())
|
||||
->withPHIDs($commit_phids)
|
||||
->execute();
|
||||
$commits = msort($commits, 'getEpoch');
|
||||
return head($commits);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue