Merge "Expose query submission ID to the user"

This commit is contained in:
Edwin Kempin
2019-11-15 09:41:23 +00:00
committed by Gerrit Code Review
4 changed files with 28 additions and 0 deletions

View File

@@ -140,6 +140,11 @@ revertof:'ID'::
+ +
Changes that revert the change specified by the numeric 'ID'. Changes that revert the change specified by the numeric 'ID'.
[[submissionid]]
submissionid:'ID'::
+
Changes that have the specified submission 'ID'.
[[reviewerin]] [[reviewerin]]
reviewerin:'GROUP':: reviewerin:'GROUP'::
+ +

View File

@@ -1245,6 +1245,15 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData, ChangeQueryBuil
throw new QueryParseException("'revertof' operator is not supported by change index version"); throw new QueryParseException("'revertof' operator is not supported by change index version");
} }
@Operator
public Predicate<ChangeData> submissionId(String value) throws QueryParseException {
if (args.getSchema().hasField(ChangeField.SUBMISSIONID)) {
return new SubmissionIdPredicate(value);
}
throw new QueryParseException(
"'submissionid' operator is not supported by change index version");
}
@Override @Override
protected Predicate<ChangeData> defaultField(String query) throws QueryParseException { protected Predicate<ChangeData> defaultField(String query) throws QueryParseException {
if (query.startsWith("refs/")) { if (query.startsWith("refs/")) {

View File

@@ -2502,6 +2502,19 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
assertQueryByIds("revertof:" + changeToRevert._number, Change.id(changeThatReverts._number)); assertQueryByIds("revertof:" + changeToRevert._number, Change.id(changeThatReverts._number));
} }
@Test
public void submissionId() throws Exception {
TestRepository<Repo> repo = createProject("repo");
Change change = insert(repo, newChange(repo));
// create irrelevant change
insert(repo, newChange(repo));
gApi.changes().id(change.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(change.getChangeId()).current().submit();
String submissionId = gApi.changes().id(change.getChangeId()).get().submissionId;
assertQueryByIds("submissionid:" + submissionId, change.getId());
}
/** Change builder for helping in tests for dashboard sections. */ /** Change builder for helping in tests for dashboard sections. */
protected class DashboardChangeState { protected class DashboardChangeState {
private final Account.Id ownerId; private final Account.Id ownerId;

View File

@@ -90,6 +90,7 @@
'status:merged', 'status:merged',
'status:open', 'status:open',
'status:reviewed', 'status:reviewed',
'submissionid:',
'topic:', 'topic:',
'tr:', 'tr:',
]; ];