From 65913162e76045c698346aefe947a9a0c09bbe93 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 20 Apr 2014 11:55:29 -0700 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 2 -- ...nduitAPI_diffusion_querycommits_Method.php | 21 ++++++++++- ...eleephwork_getorigcommitmessage_Method.php | 35 ------------------- .../request/ReleephRequestEditController.php | 9 ----- 4 files changed, 20 insertions(+), 47 deletions(-) delete mode 100644 src/applications/releeph/conduit/work/ConduitAPI_releephwork_getorigcommitmessage_Method.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index cbc178ee66..ba266c91ed 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -239,7 +239,6 @@ phutil_register_library_map(array( '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_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_record_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_record_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_getbranchcommitmessage_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_record_Method' => 'ConduitAPI_releeph_Method', 'ConduitAPI_releephwork_recordpickstatus_Method' => 'ConduitAPI_releeph_Method', diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_querycommits_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_querycommits_Method.php index 9c5c3301d7..1b8cf5fa89 100644 --- a/src/applications/diffusion/conduit/ConduitAPI_diffusion_querycommits_Method.php +++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_querycommits_Method.php @@ -17,6 +17,7 @@ final class ConduitAPI_diffusion_querycommits_Method 'phids' => 'optional list', 'names' => 'optional list', 'repositoryPHID' => 'optional phid', + 'needMessages' => 'optional bool', ) + $this->getPagerParamTypes(); } @@ -25,9 +26,15 @@ final class ConduitAPI_diffusion_querycommits_Method } protected function execute(ConduitAPIRequest $request) { + $need_messages = $request->getValue('needMessages'); + $query = id(new DiffusionCommitQuery()) ->setViewer($request->getUser()); + if ($need_messages) { + $query->needCommitData(true); + } + $repository_phid = $request->getValue('repositoryPHID'); if ($repository_phid) { $repository = id(new PhabricatorRepositoryQuery()) @@ -67,7 +74,7 @@ final class ConduitAPI_diffusion_querycommits_Method $uri = '/r'.$callsign.$identifier; $uri = PhabricatorEnv::getProductionURI($uri); - $data[$commit->getPHID()] = array( + $dict = array( 'id' => $commit->getID(), 'phid' => $commit->getPHID(), 'repositoryPHID' => $commit->getRepository()->getPHID(), @@ -75,7 +82,19 @@ final class ConduitAPI_diffusion_querycommits_Method 'epoch' => $commit->getEpoch(), 'uri' => $uri, '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( diff --git a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getorigcommitmessage_Method.php b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getorigcommitmessage_Method.php deleted file mode 100644 index 4c6efe55e2..0000000000 --- a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getorigcommitmessage_Method.php +++ /dev/null @@ -1,35 +0,0 @@ - '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); - } -} diff --git a/src/applications/releeph/controller/request/ReleephRequestEditController.php b/src/applications/releeph/controller/request/ReleephRequestEditController.php index b87e48794f..e161d94395 100644 --- a/src/applications/releeph/controller/request/ReleephRequestEditController.php +++ b/src/applications/releeph/controller/request/ReleephRequestEditController.php @@ -109,15 +109,6 @@ final class ReleephRequestEditController extends ReleephBranchController { $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) { $object_phid = $finder->getRequestedObjectPHID(); if (!$object_phid) {