Differential D21510 Diff 51196 src/applications/diffusion/conduit/DiffusionMergedCommitsQueryConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/conduit/DiffusionMergedCommitsQueryConduitAPIMethod.php
| Show All 29 Lines | final class DiffusionMergedCommitsQueryConduitAPIMethod | ||||
| protected function getGitResult(ConduitAPIRequest $request) { | protected function getGitResult(ConduitAPIRequest $request) { | ||||
| $drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
| $repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
| $commit = $request->getValue('commit'); | $commit = $request->getValue('commit'); | ||||
| $limit = $this->getLimit($request); | $limit = $this->getLimit($request); | ||||
| list($parents) = $repository->execxLocalCommand( | list($parents) = $repository->execxLocalCommand( | ||||
| 'log -n 1 --format=%s %s', | 'log -n 1 --format=%s %s --', | ||||
| '%P', | '%P', | ||||
| $commit); | gitsprintf('%s', $commit)); | ||||
| $parents = preg_split('/\s+/', trim($parents)); | $parents = preg_split('/\s+/', trim($parents)); | ||||
| if (count($parents) < 2) { | if (count($parents) < 2) { | ||||
| // This is not a merge commit, so it doesn't merge anything. | // This is not a merge commit, so it doesn't merge anything. | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| // Get all of the commits which are not reachable from the first parent. | // Get all of the commits which are not reachable from the first parent. | ||||
| // These are the commits this change merges. | // These are the commits this change merges. | ||||
| $first_parent = head($parents); | $first_parent = head($parents); | ||||
| list($logs) = $repository->execxLocalCommand( | list($logs) = $repository->execxLocalCommand( | ||||
| 'log -n %d --format=%s %s %s --', | 'log -n %d --format=%s %s %s --', | ||||
| // NOTE: "+ 1" accounts for the merge commit itself. | // NOTE: "+ 1" accounts for the merge commit itself. | ||||
| $limit + 1, | $limit + 1, | ||||
| '%H', | '%H', | ||||
| $commit, | gitsprintf('%s', $commit), | ||||
| '^'.$first_parent); | gitsprintf('%s', '^'.$first_parent)); | ||||
| $hashes = explode("\n", trim($logs)); | $hashes = explode("\n", trim($logs)); | ||||
| // Remove the merge commit. | // Remove the merge commit. | ||||
| $hashes = array_diff($hashes, array($commit)); | $hashes = array_diff($hashes, array($commit)); | ||||
| $history = DiffusionQuery::loadHistoryForCommitIdentifiers( | $history = DiffusionQuery::loadHistoryForCommitIdentifiers( | ||||
| $hashes, | $hashes, | ||||
| ▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines | |||||