[releeph] Conduit failure with bad IDs
Summary: Instead of returning a blank result it throws exceptions. Fix this up a little so we get some consistency with differential Test Plan: Loaded a bad phid for releeph, returns empty list. Try a good phid and get 2 releeph merges. Reviewers: epriestley, elenaperezrioja, dschleimer, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7302
This commit is contained in:
parent
c4abf160cc
commit
4d1709651e
|
@ -46,6 +46,9 @@ final class ConduitAPI_releeph_queryrequests_Method
|
||||||
|
|
||||||
foreach ($releephRequests as $releephRequest) {
|
foreach ($releephRequests as $releephRequest) {
|
||||||
$branch = $releephRequest->loadReleephBranch();
|
$branch = $releephRequest->loadReleephBranch();
|
||||||
|
if (!$branch) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$request_commit_phid = $releephRequest->getRequestCommitPHID();
|
$request_commit_phid = $releephRequest->getRequestCommitPHID();
|
||||||
$revisionPHID =
|
$revisionPHID =
|
||||||
$query->getRevisionPHID($request_commit_phid);
|
$query->getRevisionPHID($request_commit_phid);
|
||||||
|
|
|
@ -10,6 +10,7 @@ final class ReleephRequestQuery
|
||||||
private $severities;
|
private $severities;
|
||||||
private $requestorPHIDs;
|
private $requestorPHIDs;
|
||||||
private $branchIDs;
|
private $branchIDs;
|
||||||
|
private $revisionPHIDs;
|
||||||
|
|
||||||
const STATUS_ALL = 'status-all';
|
const STATUS_ALL = 'status-all';
|
||||||
const STATUS_OPEN = 'status-open';
|
const STATUS_OPEN = 'status-open';
|
||||||
|
@ -67,22 +68,8 @@ final class ReleephRequestQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withRevisionPHIDs(array $revision_phids) {
|
public function withRevisionPHIDs(array $revision_phids) {
|
||||||
$type = PhabricatorEdgeConfig::TYPE_DREV_HAS_COMMIT;
|
$this->revisionPHIDs = $revision_phids;
|
||||||
|
return $this;
|
||||||
$edges = id(new PhabricatorEdgeQuery())
|
|
||||||
->withSourcePHIDs($revision_phids)
|
|
||||||
->withEdgeTypes(array($type))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$this->commitToRevMap = array();
|
|
||||||
|
|
||||||
foreach ($edges as $revision_phid => $edge) {
|
|
||||||
foreach ($edge[$type] as $commitPHID => $item) {
|
|
||||||
$this->commitToRevMap[$commitPHID] = $revision_phid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->requestedCommitPHIDs = array_keys($this->commitToRevMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadPage() {
|
public function loadPage() {
|
||||||
|
@ -172,6 +159,31 @@ final class ReleephRequestQuery
|
||||||
$this->requestorPHIDs);
|
$this->requestorPHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->revisionPHIDs) {
|
||||||
|
$type = PhabricatorEdgeConfig::TYPE_DREV_HAS_COMMIT;
|
||||||
|
|
||||||
|
$edges = id(new PhabricatorEdgeQuery())
|
||||||
|
->withSourcePHIDs($this->revisionPHIDs)
|
||||||
|
->withEdgeTypes(array($type))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$this->commitToRevMap = array();
|
||||||
|
foreach ($edges as $revision_phid => $edge) {
|
||||||
|
foreach ($edge[$type] as $commitPHID => $item) {
|
||||||
|
$this->commitToRevMap[$commitPHID] = $revision_phid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->commitToRevMap) {
|
||||||
|
throw new PhabricatorEmptyQueryException("Malformed Revision Phids");
|
||||||
|
}
|
||||||
|
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'requestCommitPHID IN (%Ls)',
|
||||||
|
array_keys($this->commitToRevMap));
|
||||||
|
}
|
||||||
|
|
||||||
$where[] = $this->buildPagingClause($conn_r);
|
$where[] = $this->buildPagingClause($conn_r);
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
|
|
|
@ -55,6 +55,10 @@ final class ReleephRequest extends ReleephDAO
|
||||||
*/
|
*/
|
||||||
public function getPusherIntent() {
|
public function getPusherIntent() {
|
||||||
$project = $this->loadReleephProject();
|
$project = $this->loadReleephProject();
|
||||||
|
if (!$project) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$project->getPushers()) {
|
if (!$project->getPushers()) {
|
||||||
return self::INTENT_WANT;
|
return self::INTENT_WANT;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +232,10 @@ final class ReleephRequest extends ReleephDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadReleephProject() {
|
public function loadReleephProject() {
|
||||||
return $this->loadReleephBranch()->loadReleephProject();
|
$branch = $this->loadReleephBranch();
|
||||||
|
if ($branch) {
|
||||||
|
return $branch->loadReleephProject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadPhabricatorRepositoryCommit() {
|
public function loadPhabricatorRepositoryCommit() {
|
||||||
|
|
Loading…
Reference in a new issue