From 49f3ff0e08f4a884a5a391b3ec589adfcb99c9e1 Mon Sep 17 00:00:00 2001 From: John Watson Date: Wed, 27 Nov 2013 14:35:55 -0800 Subject: [PATCH] Attach TaskPHIDs to commits in diffusion.getcommits Summary: Uses edge query to attach TaskPHIDs to commit objects Test Plan: Use conduit to getcommits with attached tasks Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7668 --- ...ConduitAPI_diffusion_getcommits_Method.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php index 173699fa80..60782ba91d 100644 --- a/src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php +++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php @@ -129,6 +129,7 @@ final class ConduitAPI_diffusion_getcommits_Method $commits = $this->addRepositoryCommitDataInformation($commits); $commits = $this->addDifferentialInformation($commits); + $commits = $this->addManiphestInformation($commits); foreach ($commits as $name => $commit) { $results[$name] = $commit; @@ -261,4 +262,31 @@ final class ConduitAPI_diffusion_getcommits_Method return $commits; } + /** + * Enhances the commits list with Maniphest information. + */ + private function addManiphestInformation(array $commits) { + $task_type = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK; + + $commit_phids = ipull($commits, 'commitPHID'); + + $edge_query = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs($commit_phids) + ->withEdgeTypes(array($task_type)); + + $edges = $edge_query->execute(); + + foreach ($commits as $name => $commit) { + $task_phids = $edge_query->getDestinationPHIDs( + array($commit['commitPHID']), + array($task_type)); + + $commits[$name] += array( + 'taskPHIDs' => $task_phids, + ); + } + + return $commits; + } + }