Merge "Support 'repository' as query parameter in change queries"

This commit is contained in:
Patrick Hiesel
2018-07-31 09:08:32 +00:00
committed by Gerrit Code Review
3 changed files with 71 additions and 0 deletions

View File

@@ -165,6 +165,25 @@ parentproject:'PROJECT'::
Changes occurring in 'PROJECT' or in one of the child projects of Changes occurring in 'PROJECT' or in one of the child projects of
'PROJECT'. 'PROJECT'.
[[repository]]
repository:'REPOSITORY'::
+
Changes occurring in 'REPOSITORY'. If 'REPOSITORY' starts with `^` it
matches repository names by regular expression. The
link:http://www.brics.dk/automaton/[dk.brics.automaton
library] is used for evaluation of such patterns.
[[repositories]]
repositories:'PREFIX'::
+
Changes occurring in repositories starting with 'PREFIX'.
[[parentrepository]]
parentrepository:'REPOSITORY'::
+
Changes occurring in 'REPOSITORY' or in one of the child repositories of
'REPOSITORY'.
[[branch]] [[branch]]
branch:'BRANCH':: branch:'BRANCH'::
+ +

View File

@@ -657,6 +657,21 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
return new ParentProjectPredicate(args.projectCache, args.childProjects, name); return new ParentProjectPredicate(args.projectCache, args.childProjects, name);
} }
@Operator
public Predicate<ChangeData> repository(String name) {
return project(name);
}
@Operator
public Predicate<ChangeData> repositories(String name) {
return projects(name);
}
@Operator
public Predicate<ChangeData> parentrepository(String name) {
return parentproject(name);
}
@Operator @Operator
public Predicate<ChangeData> branch(String name) { public Predicate<ChangeData> branch(String name) {
if (name.startsWith("^")) { if (name.startsWith("^")) {

View File

@@ -798,6 +798,43 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
assertQuery("projects:repo", change2, change1); assertQuery("projects:repo", change2, change1);
} }
@Test
public void byRepository() throws Exception {
TestRepository<Repo> repo1 = createProject("repo1");
TestRepository<Repo> repo2 = createProject("repo2");
Change change1 = insert(repo1, newChange(repo1));
Change change2 = insert(repo2, newChange(repo2));
assertQuery("repository:foo");
assertQuery("repository:repo");
assertQuery("repository:repo1", change1);
assertQuery("repository:repo2", change2);
}
@Test
public void byParentRepository() throws Exception {
TestRepository<Repo> repo1 = createProject("repo1");
TestRepository<Repo> repo2 = createProject("repo2", "repo1");
Change change1 = insert(repo1, newChange(repo1));
Change change2 = insert(repo2, newChange(repo2));
assertQuery("parentrepository:repo1", change2, change1);
assertQuery("parentrepository:repo2", change2);
}
@Test
public void byRepositoryPrefix() throws Exception {
TestRepository<Repo> repo1 = createProject("repo1");
TestRepository<Repo> repo2 = createProject("repo2");
Change change1 = insert(repo1, newChange(repo1));
Change change2 = insert(repo2, newChange(repo2));
assertQuery("repositories:foo");
assertQuery("repositories:repo1", change1);
assertQuery("repositories:repo2", change2);
assertQuery("repositories:repo", change2, change1);
}
@Test @Test
public void byBranchAndRef() throws Exception { public void byBranchAndRef() throws Exception {
TestRepository<Repo> repo = createProject("repo"); TestRepository<Repo> repo = createProject("repo");