Make submittable a ListChangesOption
Some scripts rely on the submittable bit from QueryChanges to
implement an 'automatically submit when approved to do so' feature,
to allow a person to mark a change as Autosubmit-Ready and go home
for the night in the expectation that a CI system will verify the
change and cause it to be submitted.
4cd05b2c5e (Only compute submittable
during submitted_together, 2016-09-17), which was needed for
performance reasons when rendering dashboards, broke these scripts.
Allow them to work again through a new o=SUBMITTABLE option.
Change-Id: Ia6ce6d95b1d774ede786b797eb04ce1353de6c86
This commit is contained in:
@@ -301,6 +301,12 @@ default. Optional fields are:
|
|||||||
link:user-search.html#reviewedby[reviewedby:self].
|
link:user-search.html#reviewedby[reviewedby:self].
|
||||||
--
|
--
|
||||||
|
|
||||||
|
[[submittable]]
|
||||||
|
--
|
||||||
|
* `SUBMITTABLE`: include the `submittable` field in link:#commit-info[CommitInfo],
|
||||||
|
which can be used to tell if the change is reviewed and ready for submit.
|
||||||
|
--
|
||||||
|
|
||||||
[[web-links]]
|
[[web-links]]
|
||||||
--
|
--
|
||||||
* `WEB_LINKS`: include the `web_links` field in link:#commit-info[CommitInfo],
|
* `WEB_LINKS`: include the `web_links` field in link:#commit-info[CommitInfo],
|
||||||
@@ -1420,8 +1426,9 @@ changes to be merged.
|
|||||||
The listed changes use the same format as in
|
The listed changes use the same format as in
|
||||||
link:#list-changes[Query Changes] with the
|
link:#list-changes[Query Changes] with the
|
||||||
link:#labels[`LABELS`], link:#detailed-labels[`DETAILED_LABELS`],
|
link:#labels[`LABELS`], link:#detailed-labels[`DETAILED_LABELS`],
|
||||||
link:#current-revision[`CURRENT_REVISION`], and
|
link:#current-revision[`CURRENT_REVISION`],
|
||||||
link:#current-commit[`CURRENT_COMMIT`] options set.
|
link:#current-commit[`CURRENT_COMMIT`], and
|
||||||
|
link:#submittable[`SUBMITTABLE`] options set.
|
||||||
|
|
||||||
Standard link:#query-options[formatting options] can be specified
|
Standard link:#query-options[formatting options] can be specified
|
||||||
with the `o` parameter, as well as the `submitted_together` specific
|
with the `o` parameter, as well as the `submitted_together` specific
|
||||||
@@ -4640,7 +4647,7 @@ Whether the change is mergeable. +
|
|||||||
Not set for merged changes, or if the change has not yet been tested.
|
Not set for merged changes, or if the change has not yet been tested.
|
||||||
|`submittable` |optional|
|
|`submittable` |optional|
|
||||||
Whether the change has been approved by the project submit rules. +
|
Whether the change has been approved by the project submit rules. +
|
||||||
Provided only by link:#submitted-together[submitted_together].
|
Only set if link:#submittable[requested].
|
||||||
|`insertions` ||
|
|`insertions` ||
|
||||||
Number of inserted lines.
|
Number of inserted lines.
|
||||||
|`deletions` ||
|
|`deletions` ||
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assert_;
|
|||||||
import static com.google.common.truth.TruthJUnit.assume;
|
import static com.google.common.truth.TruthJUnit.assume;
|
||||||
import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVISION;
|
import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVISION;
|
||||||
import static com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS;
|
import static com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS;
|
||||||
|
import static com.google.gerrit.extensions.client.ListChangesOption.SUBMITTABLE;
|
||||||
import static com.google.gerrit.server.group.SystemGroupBackend.CHANGE_OWNER;
|
import static com.google.gerrit.server.group.SystemGroupBackend.CHANGE_OWNER;
|
||||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
@@ -474,6 +475,9 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void assertSubmittable(String changeId) throws Exception {
|
protected void assertSubmittable(String changeId) throws Exception {
|
||||||
|
assertThat(get(changeId, SUBMITTABLE).submittable)
|
||||||
|
.named("submit bit on ChangeInfo")
|
||||||
|
.isEqualTo(true);
|
||||||
RevisionResource rsrc = parseCurrentRevisionResource(changeId);
|
RevisionResource rsrc = parseCurrentRevisionResource(changeId);
|
||||||
UiAction.Description desc = submitHandler.getDescription(rsrc);
|
UiAction.Description desc = submitHandler.getDescription(rsrc);
|
||||||
assertThat(desc.isVisible()).named("visible bit on submit action").isTrue();
|
assertThat(desc.isVisible()).named("visible bit on submit action").isTrue();
|
||||||
|
|||||||
@@ -69,7 +69,10 @@ public enum ListChangesOption {
|
|||||||
PUSH_CERTIFICATES(18),
|
PUSH_CERTIFICATES(18),
|
||||||
|
|
||||||
/** Include change's reviewer updates. */
|
/** Include change's reviewer updates. */
|
||||||
REVIEWER_UPDATES(19);
|
REVIEWER_UPDATES(19),
|
||||||
|
|
||||||
|
/** Set the submittable boolean. */
|
||||||
|
SUBMITTABLE(20);
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import static com.google.gerrit.extensions.client.ListChangesOption.MESSAGES;
|
|||||||
import static com.google.gerrit.extensions.client.ListChangesOption.PUSH_CERTIFICATES;
|
import static com.google.gerrit.extensions.client.ListChangesOption.PUSH_CERTIFICATES;
|
||||||
import static com.google.gerrit.extensions.client.ListChangesOption.REVIEWED;
|
import static com.google.gerrit.extensions.client.ListChangesOption.REVIEWED;
|
||||||
import static com.google.gerrit.extensions.client.ListChangesOption.REVIEWER_UPDATES;
|
import static com.google.gerrit.extensions.client.ListChangesOption.REVIEWER_UPDATES;
|
||||||
|
import static com.google.gerrit.extensions.client.ListChangesOption.SUBMITTABLE;
|
||||||
import static com.google.gerrit.extensions.client.ListChangesOption.WEB_LINKS;
|
import static com.google.gerrit.extensions.client.ListChangesOption.WEB_LINKS;
|
||||||
import static com.google.gerrit.server.CommonConverters.toGitPerson;
|
import static com.google.gerrit.server.CommonConverters.toGitPerson;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
@@ -177,7 +178,6 @@ public class ChangeJson {
|
|||||||
|
|
||||||
private boolean lazyLoad = true;
|
private boolean lazyLoad = true;
|
||||||
private AccountLoader accountLoader;
|
private AccountLoader accountLoader;
|
||||||
private boolean includeSubmittable;
|
|
||||||
private Map<Change.Id, List<SubmitRecord>> submitRecords;
|
private Map<Change.Id, List<SubmitRecord>> submitRecords;
|
||||||
private FixInput fix;
|
private FixInput fix;
|
||||||
|
|
||||||
@@ -233,11 +233,6 @@ public class ChangeJson {
|
|||||||
: EnumSet.copyOf(options);
|
: EnumSet.copyOf(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeJson includeSubmittable(boolean include) {
|
|
||||||
includeSubmittable = include;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChangeJson lazyLoad(boolean load) {
|
public ChangeJson lazyLoad(boolean load) {
|
||||||
lazyLoad = load;
|
lazyLoad = load;
|
||||||
return this;
|
return this;
|
||||||
@@ -454,7 +449,7 @@ public class ChangeJson {
|
|||||||
out.submitType = str.type;
|
out.submitType = str.type;
|
||||||
}
|
}
|
||||||
out.mergeable = cd.isMergeable();
|
out.mergeable = cd.isMergeable();
|
||||||
if (includeSubmittable) {
|
if (has(SUBMITTABLE)) {
|
||||||
out.submittable = submittable(cd);
|
out.submittable = submittable(cd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
|||||||
|
|
||||||
private final EnumSet<ListChangesOption> jsonOpt = EnumSet.of(
|
private final EnumSet<ListChangesOption> jsonOpt = EnumSet.of(
|
||||||
ListChangesOption.CURRENT_REVISION,
|
ListChangesOption.CURRENT_REVISION,
|
||||||
ListChangesOption.CURRENT_COMMIT);
|
ListChangesOption.CURRENT_COMMIT,
|
||||||
|
ListChangesOption.SUBMITTABLE);
|
||||||
|
|
||||||
private final ChangeJson.Factory json;
|
private final ChangeJson.Factory json;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
private final Provider<ReviewDb> dbProvider;
|
||||||
@@ -152,9 +153,7 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SubmittedTogetherInfo info = new SubmittedTogetherInfo();
|
SubmittedTogetherInfo info = new SubmittedTogetherInfo();
|
||||||
info.changes = json.create(jsonOpt)
|
info.changes = json.create(jsonOpt).formatChangeDatas(cds);
|
||||||
.includeSubmittable(true)
|
|
||||||
.formatChangeDatas(cds);
|
|
||||||
info.nonVisibleChanges = hidden;
|
info.nonVisibleChanges = hidden;
|
||||||
return info;
|
return info;
|
||||||
} catch (OrmException | IOException e) {
|
} catch (OrmException | IOException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user