mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 09:58:24 +01:00
Replace magical "branch" behavior in "diffusion.branchquery" with an explicit "patterns"
Summary: See PHI958. Ref T13210. Previously, see PHI720. The use case for the magic in PHI720 involves multiple patterns, and no parameter can be passed to `branch` that will result in multiple patterns being passed to `git`. Replace the implicit magic with an explicit `patterns` parameter. This whole thing is a bit shaky but probably isn't hurting anything. Test Plan: - Ran query with no `patterns`. - Ran query with invalid `patterns`, got readable error. - Ran query with various valid `patterns` (plain branch name, globs with "?" and "*"), got sensible results. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13210 Differential Revision: https://secure.phabricator.com/D19771
This commit is contained in:
parent
da40f80741
commit
e26c4bddab
1 changed files with 14 additions and 11 deletions
|
@ -21,6 +21,7 @@ final class DiffusionBranchQueryConduitAPIMethod
|
||||||
'limit' => 'optional int',
|
'limit' => 'optional int',
|
||||||
'offset' => 'optional int',
|
'offset' => 'optional int',
|
||||||
'contains' => 'optional string',
|
'contains' => 'optional string',
|
||||||
|
'patterns' => 'optional list<string>',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,15 +32,17 @@ final class DiffusionBranchQueryConduitAPIMethod
|
||||||
$contains = $request->getValue('contains');
|
$contains = $request->getValue('contains');
|
||||||
if (strlen($contains)) {
|
if (strlen($contains)) {
|
||||||
|
|
||||||
// See PHI720. If the standard "branch" field is provided, use it
|
// See PHI958 (and, earlier, PHI720). If "patterns" are provided, pass
|
||||||
// as the "pattern" argument to "git branch ..." to let callers test
|
// them to "git branch ..." to let callers test for reachability from
|
||||||
// for reachability from a particular branch head.
|
// particular branch heads.
|
||||||
$pattern = $request->getValue('branch');
|
$patterns_argv = $request->getValue('patterns', array());
|
||||||
if (strlen($pattern)) {
|
PhutilTypeSpec::checkMap(
|
||||||
$pattern_argv = array($pattern);
|
array(
|
||||||
} else {
|
'patterns' => $patterns_argv,
|
||||||
$pattern_argv = array();
|
),
|
||||||
}
|
array(
|
||||||
|
'patterns' => 'list<string>',
|
||||||
|
));
|
||||||
|
|
||||||
// NOTE: We can't use DiffusionLowLevelGitRefQuery here because
|
// NOTE: We can't use DiffusionLowLevelGitRefQuery here because
|
||||||
// `git for-each-ref` does not support `--contains`.
|
// `git for-each-ref` does not support `--contains`.
|
||||||
|
@ -47,14 +50,14 @@ final class DiffusionBranchQueryConduitAPIMethod
|
||||||
list($stdout) = $repository->execxLocalCommand(
|
list($stdout) = $repository->execxLocalCommand(
|
||||||
'branch --verbose --no-abbrev --contains %s -- %Ls',
|
'branch --verbose --no-abbrev --contains %s -- %Ls',
|
||||||
$contains,
|
$contains,
|
||||||
$pattern_argv);
|
$patterns_argv);
|
||||||
$ref_map = DiffusionGitBranch::parseLocalBranchOutput(
|
$ref_map = DiffusionGitBranch::parseLocalBranchOutput(
|
||||||
$stdout);
|
$stdout);
|
||||||
} else {
|
} else {
|
||||||
list($stdout) = $repository->execxLocalCommand(
|
list($stdout) = $repository->execxLocalCommand(
|
||||||
'branch -r --verbose --no-abbrev --contains %s -- %Ls',
|
'branch -r --verbose --no-abbrev --contains %s -- %Ls',
|
||||||
$contains,
|
$contains,
|
||||||
$pattern_argv);
|
$patterns_argv);
|
||||||
$ref_map = DiffusionGitBranch::parseRemoteBranchOutput(
|
$ref_map = DiffusionGitBranch::parseRemoteBranchOutput(
|
||||||
$stdout,
|
$stdout,
|
||||||
DiffusionGitBranch::DEFAULT_GIT_REMOTE);
|
DiffusionGitBranch::DEFAULT_GIT_REMOTE);
|
||||||
|
|
Loading…
Add table
Reference in a new issue