diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 080ba7456f..fd8be406e7 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -530,6 +530,7 @@ phutil_register_library_map(array( 'DiffusionPushLogListController' => 'applications/diffusion/controller/DiffusionPushLogListController.php', 'DiffusionQuery' => 'applications/diffusion/query/DiffusionQuery.php', 'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php', + 'DiffusionRefNotFoundException' => 'applications/diffusion/exception/DiffusionRefNotFoundException.php', 'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php', 'DiffusionRepositoryController' => 'applications/diffusion/controller/DiffusionRepositoryController.php', 'DiffusionRepositoryCreateController' => 'applications/diffusion/controller/DiffusionRepositoryCreateController.php', @@ -3172,6 +3173,7 @@ phutil_register_library_map(array( ), 'DiffusionQuery' => 'PhabricatorQuery', 'DiffusionRawDiffQuery' => 'DiffusionQuery', + 'DiffusionRefNotFoundException' => 'Exception', 'DiffusionRepositoryController' => 'DiffusionController', 'DiffusionRepositoryCreateController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryDefaultController' => 'DiffusionController', diff --git a/src/applications/diffusion/exception/DiffusionRefNotFoundException.php b/src/applications/diffusion/exception/DiffusionRefNotFoundException.php new file mode 100644 index 0000000000..8dda27d072 --- /dev/null +++ b/src/applications/diffusion/exception/DiffusionRefNotFoundException.php @@ -0,0 +1,16 @@ +ref = $ref; + return $this; + } + + public function getRef() { + return $this->ref; + } + +} diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php index db64e1841c..dd20d7380e 100644 --- a/src/applications/diffusion/request/DiffusionRequest.php +++ b/src/applications/diffusion/request/DiffusionRequest.php @@ -4,11 +4,8 @@ * Contains logic to parse Diffusion requests, which have a complicated URI * structure. * - * * @task new Creating Requests * @task uri Managing Diffusion URIs - * - * @group diffusion */ abstract class DiffusionRequest { @@ -644,17 +641,18 @@ abstract class DiffusionRequest { } if ($this->getSupportsBranches()) { - $branch = $this->getResolvableBranchName($this->getBranch()); + $ref = $this->getResolvableBranchName($this->getBranch()); } else { - $branch = 'HEAD'; + $ref = 'HEAD'; } - $results = $this->resolveRefs(array($branch)); + $results = $this->resolveRefs(array($ref)); - $matches = idx($results, $branch, array()); + $matches = idx($results, $ref, array()); if (count($matches) !== 1) { - throw new Exception( - pht('Ref "%s" is ambiguous or does not exist.', $branch)); + $message = pht('Ref "%s" is ambiguous or does not exist.', $ref); + throw id(new DiffusionRefNotFoundException($message)) + ->setRef($ref); } $this->stableCommit = idx(head($matches), 'identifier');