Support change~branch~id in query syntax
It is odd that we describe this in the REST API as a canonical way of referring to a change, but don't support it in the query syntax. Since the query parser is also used by the /r handler, this fixes that there as well. Unlike in the ChangesCollection parser, allow prefix searches for the id portion, to be consistent with other search operators. Change-Id: I55e1cc33caf907cb0ff17dae7a81a46156b6f562
This commit is contained in:
@@ -50,6 +50,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountManager;
|
||||
import com.google.gerrit.server.account.AuthRequest;
|
||||
import com.google.gerrit.server.change.ChangeInserter;
|
||||
import com.google.gerrit.server.change.ChangeTriplet;
|
||||
import com.google.gerrit.server.change.ChangesCollection;
|
||||
import com.google.gerrit.server.change.PostReview;
|
||||
import com.google.gerrit.server.change.RevisionResource;
|
||||
@@ -206,6 +207,33 @@ public abstract class AbstractQueryChangesTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byTriplet() throws Exception {
|
||||
TestRepository<InMemoryRepository> repo = createProject("repo");
|
||||
Change change = newChange(repo, null, null, null, "branch").insert();
|
||||
String k = change.getKey().get();
|
||||
|
||||
assertResultEquals(change, queryOne("repo~branch~" + k));
|
||||
assertResultEquals(change, queryOne("change:repo~branch~" + k));
|
||||
assertResultEquals(change, queryOne("repo~refs/heads/branch~" + k));
|
||||
assertResultEquals(change, queryOne("change:repo~refs/heads/branch~" + k));
|
||||
assertResultEquals(change, queryOne("repo~branch~" + k.substring(0, 10)));
|
||||
assertResultEquals(change,
|
||||
queryOne("change:repo~branch~" + k.substring(0, 10)));
|
||||
|
||||
assertThat(query("foo~bar")).isEmpty();
|
||||
assertBadQuery("change:foo~bar");
|
||||
assertThat(query("otherrepo~branch~" + k)).isEmpty();
|
||||
assertThat(query("change:otherrepo~branch~" + k)).isEmpty();
|
||||
assertThat(query("repo~otherbranch~" + k)).isEmpty();
|
||||
assertThat(query("change:repo~otherbranch~" + k)).isEmpty();
|
||||
assertThat(query("repo~branch~I0000000000000000000000000000000000000000"))
|
||||
.isEmpty();
|
||||
assertThat(query(
|
||||
"change:repo~branch~I0000000000000000000000000000000000000000"))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byStatus() throws Exception {
|
||||
TestRepository<InMemoryRepository> repo = createProject("repo");
|
||||
@@ -990,6 +1018,7 @@ public abstract class AbstractQueryChangesTest {
|
||||
|
||||
assertResultEquals(change1,
|
||||
queryOne(Integer.toString(change1.getId().get())));
|
||||
assertResultEquals(change1, queryOne(ChangeTriplet.format(change1)));
|
||||
assertResultEquals(change2, queryOne("foosubject"));
|
||||
assertResultEquals(change3, queryOne("Foo.java"));
|
||||
assertResultEquals(change4, queryOne("Code-Review+1"));
|
||||
|
Reference in New Issue
Block a user