mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Allow discovered but unparsed commits to be requested in Releeph
Summary: Ref T3662. Releeph blocks users from requsting unparsed commits, but there's no real technical reason for this. The `releephwork.getorigcommitmessage` method assumes data exists, but should be replaced with `diffusion.querycommits` anyway. Test Plan: Ran `diffusion.querycommits`. Requested a commit. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T3662 Differential Revision: https://secure.phabricator.com/D8823
This commit is contained in:
parent
1a3ac09975
commit
65913162e7
4 changed files with 20 additions and 47 deletions
|
@ -239,7 +239,6 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_releephwork_getbranch_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_getbranch_Method.php',
|
'ConduitAPI_releephwork_getbranch_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_getbranch_Method.php',
|
||||||
'ConduitAPI_releephwork_getbranchcommitmessage_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_getbranchcommitmessage_Method.php',
|
'ConduitAPI_releephwork_getbranchcommitmessage_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_getbranchcommitmessage_Method.php',
|
||||||
'ConduitAPI_releephwork_getcommitmessage_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_getcommitmessage_Method.php',
|
'ConduitAPI_releephwork_getcommitmessage_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_getcommitmessage_Method.php',
|
||||||
'ConduitAPI_releephwork_getorigcommitmessage_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_getorigcommitmessage_Method.php',
|
|
||||||
'ConduitAPI_releephwork_nextrequest_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php',
|
'ConduitAPI_releephwork_nextrequest_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php',
|
||||||
'ConduitAPI_releephwork_record_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_record_Method.php',
|
'ConduitAPI_releephwork_record_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_record_Method.php',
|
||||||
'ConduitAPI_releephwork_recordpickstatus_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_recordpickstatus_Method.php',
|
'ConduitAPI_releephwork_recordpickstatus_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_recordpickstatus_Method.php',
|
||||||
|
@ -2827,7 +2826,6 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_releephwork_getbranch_Method' => 'ConduitAPI_releeph_Method',
|
'ConduitAPI_releephwork_getbranch_Method' => 'ConduitAPI_releeph_Method',
|
||||||
'ConduitAPI_releephwork_getbranchcommitmessage_Method' => 'ConduitAPI_releeph_Method',
|
'ConduitAPI_releephwork_getbranchcommitmessage_Method' => 'ConduitAPI_releeph_Method',
|
||||||
'ConduitAPI_releephwork_getcommitmessage_Method' => 'ConduitAPI_releeph_Method',
|
'ConduitAPI_releephwork_getcommitmessage_Method' => 'ConduitAPI_releeph_Method',
|
||||||
'ConduitAPI_releephwork_getorigcommitmessage_Method' => 'ConduitAPI_releeph_Method',
|
|
||||||
'ConduitAPI_releephwork_nextrequest_Method' => 'ConduitAPI_releeph_Method',
|
'ConduitAPI_releephwork_nextrequest_Method' => 'ConduitAPI_releeph_Method',
|
||||||
'ConduitAPI_releephwork_record_Method' => 'ConduitAPI_releeph_Method',
|
'ConduitAPI_releephwork_record_Method' => 'ConduitAPI_releeph_Method',
|
||||||
'ConduitAPI_releephwork_recordpickstatus_Method' => 'ConduitAPI_releeph_Method',
|
'ConduitAPI_releephwork_recordpickstatus_Method' => 'ConduitAPI_releeph_Method',
|
||||||
|
|
|
@ -17,6 +17,7 @@ final class ConduitAPI_diffusion_querycommits_Method
|
||||||
'phids' => 'optional list<phid>',
|
'phids' => 'optional list<phid>',
|
||||||
'names' => 'optional list<string>',
|
'names' => 'optional list<string>',
|
||||||
'repositoryPHID' => 'optional phid',
|
'repositoryPHID' => 'optional phid',
|
||||||
|
'needMessages' => 'optional bool',
|
||||||
) + $this->getPagerParamTypes();
|
) + $this->getPagerParamTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +26,15 @@ final class ConduitAPI_diffusion_querycommits_Method
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(ConduitAPIRequest $request) {
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
|
$need_messages = $request->getValue('needMessages');
|
||||||
|
|
||||||
$query = id(new DiffusionCommitQuery())
|
$query = id(new DiffusionCommitQuery())
|
||||||
->setViewer($request->getUser());
|
->setViewer($request->getUser());
|
||||||
|
|
||||||
|
if ($need_messages) {
|
||||||
|
$query->needCommitData(true);
|
||||||
|
}
|
||||||
|
|
||||||
$repository_phid = $request->getValue('repositoryPHID');
|
$repository_phid = $request->getValue('repositoryPHID');
|
||||||
if ($repository_phid) {
|
if ($repository_phid) {
|
||||||
$repository = id(new PhabricatorRepositoryQuery())
|
$repository = id(new PhabricatorRepositoryQuery())
|
||||||
|
@ -67,7 +74,7 @@ final class ConduitAPI_diffusion_querycommits_Method
|
||||||
$uri = '/r'.$callsign.$identifier;
|
$uri = '/r'.$callsign.$identifier;
|
||||||
$uri = PhabricatorEnv::getProductionURI($uri);
|
$uri = PhabricatorEnv::getProductionURI($uri);
|
||||||
|
|
||||||
$data[$commit->getPHID()] = array(
|
$dict = array(
|
||||||
'id' => $commit->getID(),
|
'id' => $commit->getID(),
|
||||||
'phid' => $commit->getPHID(),
|
'phid' => $commit->getPHID(),
|
||||||
'repositoryPHID' => $commit->getRepository()->getPHID(),
|
'repositoryPHID' => $commit->getRepository()->getPHID(),
|
||||||
|
@ -75,7 +82,19 @@ final class ConduitAPI_diffusion_querycommits_Method
|
||||||
'epoch' => $commit->getEpoch(),
|
'epoch' => $commit->getEpoch(),
|
||||||
'uri' => $uri,
|
'uri' => $uri,
|
||||||
'isImporting' => !$commit->isImported(),
|
'isImporting' => !$commit->isImported(),
|
||||||
|
'summary' => $commit->getSummary(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($need_messages) {
|
||||||
|
$commit_data = $commit->getCommitData();
|
||||||
|
if ($commit_data) {
|
||||||
|
$dict['message'] = $commit_data->getCommitMessage();
|
||||||
|
} else {
|
||||||
|
$dict['message'] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data[$commit->getPHID()] = $dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array(
|
$result = array(
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class ConduitAPI_releephwork_getorigcommitmessage_Method
|
|
||||||
extends ConduitAPI_releeph_Method {
|
|
||||||
|
|
||||||
public function getMethodStatus() {
|
|
||||||
return self::METHOD_STATUS_UNSTABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMethodDescription() {
|
|
||||||
return "Return the original commit message for the given commit.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function defineParamTypes() {
|
|
||||||
return array(
|
|
||||||
'commitPHID' => 'required string',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function defineReturnType() {
|
|
||||||
return 'nonempty string';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function defineErrorTypes() {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(ConduitAPIRequest $request) {
|
|
||||||
$commit = id(new PhabricatorRepositoryCommit())
|
|
||||||
->loadOneWhere('phid = %s', $request->getValue('commitPHID'));
|
|
||||||
$commit_data = $commit->loadCommitData();
|
|
||||||
$commit_message = $commit_data->getCommitMessage();
|
|
||||||
return trim($commit_message);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -109,15 +109,6 @@ final class ReleephRequestEditController extends ReleephBranchController {
|
||||||
$errors[] = $e->getMessage();
|
$errors[] = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$pr_commit_data = null;
|
|
||||||
if (!$errors) {
|
|
||||||
$pr_commit_data = $pr_commit->loadCommitData();
|
|
||||||
if (!$pr_commit_data) {
|
|
||||||
$e_request_identifier = 'Not parsed yet';
|
|
||||||
$errors[] = "The requested commit hasn't been parsed yet.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$errors) {
|
if (!$errors) {
|
||||||
$object_phid = $finder->getRequestedObjectPHID();
|
$object_phid = $finder->getRequestedObjectPHID();
|
||||||
if (!$object_phid) {
|
if (!$object_phid) {
|
||||||
|
|
Loading…
Reference in a new issue