From 36a6fcb573214058e7d135c12f700ae4104bec9b Mon Sep 17 00:00:00 2001 From: adonohue Date: Thu, 19 May 2011 15:36:17 -0700 Subject: [PATCH] diffusion.getrecentcommitsbypath Summary: Implement diffusion.getrecentcommitsbypath, a Conduit wrapper over DiffusionHistoryQuery which returns results suitable for consumption by diffusion.getcommits. Test Plan: Conduit console Reviewed By: epriestley Reviewers: epriestley CC: aran, epriestley Differential Revision: 315 --- src/__phutil_library_map__.php | 2 + ...iffusion_getrecentcommitsbypath_Method.php | 62 +++++++++++++++++++ .../getrecentcommitsbypath/__init__.php | 16 +++++ .../celerity/controller/__init__.php | 1 + 4 files changed, 81 insertions(+) create mode 100644 src/applications/conduit/method/diffusion/getrecentcommitsbypath/ConduitAPI_diffusion_getrecentcommitsbypath_Method.php create mode 100644 src/applications/conduit/method/diffusion/getrecentcommitsbypath/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ba2786116c..3fd72b4d28 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -95,6 +95,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision', 'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'applications/conduit/method/differential/updatetaskrevisionassoc', 'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits', + 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'applications/conduit/method/diffusion/getrecentcommitsbypath', 'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload', 'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners', 'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find', @@ -588,6 +589,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'ConduitAPIMethod', 'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod', + 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod', 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/method/diffusion/getrecentcommitsbypath/ConduitAPI_diffusion_getrecentcommitsbypath_Method.php b/src/applications/conduit/method/diffusion/getrecentcommitsbypath/ConduitAPI_diffusion_getrecentcommitsbypath_Method.php new file mode 100644 index 0000000000..335e106f0f --- /dev/null +++ b/src/applications/conduit/method/diffusion/getrecentcommitsbypath/ConduitAPI_diffusion_getrecentcommitsbypath_Method.php @@ -0,0 +1,62 @@ + 'required string', + 'path' => 'required string', + ); + } + + public function defineReturnType() { + return 'nonempty list'; + } + + public function defineErrorTypes() { + return array( + ); + } + + protected function execute(ConduitAPIRequest $request) { + $results = array(); + + $history = DiffusionHistoryQuery::newFromDiffusionRequest( + DiffusionRequest::newFromAphrontRequestDictionary( + $request->getAllParameters() + ) + ) + ->setLimit(self::RESULT_LIMIT) + ->loadHistory(); + + $raw_commit_identifiers = mpull($history, 'getCommitIdentifier'); + $result = array(); + foreach ($raw_commit_identifiers as $id) { + $result[] = 'r'.$request->getValue('callsign').$id; + } + return $result; + } +} diff --git a/src/applications/conduit/method/diffusion/getrecentcommitsbypath/__init__.php b/src/applications/conduit/method/diffusion/getrecentcommitsbypath/__init__.php new file mode 100644 index 0000000000..e3a929465c --- /dev/null +++ b/src/applications/conduit/method/diffusion/getrecentcommitsbypath/__init__.php @@ -0,0 +1,16 @@ +