Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14049284
D12553.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D12553.diff
View Options
diff --git a/src/applications/diffusion/conduit/DiffusionResolveRefsConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionResolveRefsConduitAPIMethod.php
--- a/src/applications/diffusion/conduit/DiffusionResolveRefsConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionResolveRefsConduitAPIMethod.php
@@ -18,16 +18,23 @@
protected function defineCustomParamTypes() {
return array(
'refs' => 'required list<string>',
+ 'types' => 'optional list<string>',
);
}
protected function getResult(ConduitAPIRequest $request) {
$refs = $request->getValue('refs');
+ $types = $request->getValue('types');
- return id(new DiffusionLowLevelResolveRefsQuery())
+ $query = id(new DiffusionLowLevelResolveRefsQuery())
->setRepository($this->getDiffusionRequest()->getRepository())
- ->withRefs($refs)
- ->execute();
+ ->withRefs($refs);
+
+ if ($types) {
+ $query->withTypes($types);
+ }
+
+ return $query->execute();
}
}
diff --git a/src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php b/src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php
--- a/src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php
+++ b/src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php
@@ -16,12 +16,18 @@
extends DiffusionLowLevelQuery {
private $refs;
+ private $types;
public function withRefs(array $refs) {
$this->refs = $refs;
return $this;
}
+ public function withTypes(array $types) {
+ $this->types = $types;
+ return $this;
+ }
+
protected function executeQuery() {
if (!$this->refs) {
return array();
@@ -39,6 +45,10 @@
throw new Exception('Unsupported repository type!');
}
+ if ($this->types !== null) {
+ $result = $this->filterRefsByType($result, $this->types);
+ }
+
return $result;
}
diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php
--- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php
@@ -23,4 +23,21 @@
return $this->executeQuery();
}
+ protected function filterRefsByType(array $refs, array $types) {
+ $type_map = array_fuse($types);
+
+ foreach ($refs as $name => $ref_list) {
+ foreach ($ref_list as $key => $ref) {
+ if (empty($type_map[$ref['type']])) {
+ unset($refs[$name][$key]);
+ }
+ }
+ if (!$refs[$name]) {
+ unset($refs[$name]);
+ }
+ }
+
+ return $refs;
+ }
+
}
diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
--- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
@@ -14,12 +14,18 @@
extends DiffusionLowLevelQuery {
private $refs;
+ private $types;
public function withRefs(array $refs) {
$this->refs = $refs;
return $this;
}
+ public function withTypes(array $types) {
+ $this->types = $types;
+ return $this;
+ }
+
protected function executeQuery() {
if (!$this->refs) {
return array();
@@ -39,6 +45,10 @@
throw new Exception('Unsupported repository type!');
}
+ if ($this->types !== null) {
+ $result = $this->filterRefsByType($result, $this->types);
+ }
+
return $result;
}
diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php
--- a/src/applications/diffusion/request/DiffusionRequest.php
+++ b/src/applications/diffusion/request/DiffusionRequest.php
@@ -718,17 +718,21 @@
}
private function queryStableCommit() {
+ $types = array();
if ($this->symbolicCommit) {
$ref = $this->symbolicCommit;
} else {
if ($this->supportsBranches()) {
$ref = $this->getResolvableBranchName($this->getBranch());
+ $types = array(
+ PhabricatorRepositoryRefCursor::TYPE_BRANCH,
+ );
} else {
$ref = 'HEAD';
}
}
- $results = $this->resolveRefs(array($ref));
+ $results = $this->resolveRefs(array($ref), $types);
$matches = idx($results, $ref, array());
if (!$matches) {
@@ -790,12 +794,17 @@
return $branch;
}
- private function resolveRefs(array $refs) {
+ private function resolveRefs(array $refs, array $types) {
// First, try to resolve refs from fast cache sources.
- $cached_results = id(new DiffusionCachedResolveRefsQuery())
+ $cached_query = id(new DiffusionCachedResolveRefsQuery())
->setRepository($this->getRepository())
- ->withRefs($refs)
- ->execute();
+ ->withRefs($refs);
+
+ if ($types) {
+ $cached_query->withTypes($types);
+ }
+
+ $cached_results = $cached_query->execute();
// Throw away all the refs we resolved. Hopefully, we'll throw away
// everything here.
@@ -813,6 +822,7 @@
$this,
'diffusion.resolverefs',
array(
+ 'types' => $types,
'refs' => $refs,
));
} else {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 12:17 PM (3 d, 21 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714463
Default Alt Text
D12553.diff (5 KB)
Attached To
Mode
D12553: Only resolve branch names to branches
Attached
Detach File
Event Timeline
Log In to Comment