ChangeJson: Include change kind in revision info
Change-Id: I00ff6eb125ecdd995832d07dff5d779a863712dd
This commit is contained in:
@@ -353,6 +353,7 @@ default. Optional fields are:
|
||||
"current_revision": "184ebe53805e102605d11f6b143486d15c23a09c",
|
||||
"revisions": {
|
||||
"184ebe53805e102605d11f6b143486d15c23a09c": {
|
||||
"kind": "REWORK",
|
||||
"_number": 1,
|
||||
"ref": "refs/changes/97/97/1",
|
||||
"fetch": {
|
||||
@@ -936,6 +937,7 @@ is included.
|
||||
"current_revision": "27cc4558b5a3d3387dd11ee2df7a117e7e581822",
|
||||
"revisions": {
|
||||
"27cc4558b5a3d3387dd11ee2df7a117e7e581822": {
|
||||
"kind": "REWORK",
|
||||
"_number": 2,
|
||||
"ref": "refs/changes/99/4799/2",
|
||||
"fetch": {
|
||||
@@ -1314,6 +1316,7 @@ link:#current-commit[\{CURRENT_COMMIT\}] set.
|
||||
"current_revision": "9adb9f4c7b40eeee0646e235de818d09164d7379",
|
||||
"revisions": {
|
||||
"9adb9f4c7b40eeee0646e235de818d09164d7379": {
|
||||
"kind": "REWORK",
|
||||
"_number": 1,
|
||||
"created": "2015-05-01 15:39:57.979000000",
|
||||
"uploader": {
|
||||
@@ -1432,6 +1435,7 @@ link:#current-commit[\{CURRENT_COMMIT\}] set.
|
||||
"current_revision": "1bd7c12a38854a2c6de426feec28800623f492c4",
|
||||
"revisions": {
|
||||
"1bd7c12a38854a2c6de426feec28800623f492c4": {
|
||||
"kind": "REWORK",
|
||||
"_number": 1,
|
||||
"created": "2015-05-01 15:39:57.979000000",
|
||||
"uploader": {
|
||||
@@ -2659,12 +2663,14 @@ for the current patch set.
|
||||
"current_revision": "674ac754f91e64a0efb8087e59a176484bd534d1",
|
||||
"revisions": {
|
||||
"674ac754f91e64a0efb8087e59a176484bd534d1": {
|
||||
"_number": 2,
|
||||
"ref": "refs/changes/65/3965/2",
|
||||
"fetch": {
|
||||
"http": {
|
||||
"url": "http://gerrit/myProject",
|
||||
"ref": "refs/changes/65/3965/2"
|
||||
"kind": "REWORK",
|
||||
"_number": 2,
|
||||
"ref": "refs/changes/65/3965/2",
|
||||
"fetch": {
|
||||
"http": {
|
||||
"url": "http://gerrit/myProject",
|
||||
"ref": "refs/changes/65/3965/2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2863,6 +2869,7 @@ is included.
|
||||
"current_revision": "27cc4558b5a3d3387dd11ee2df7a117e7e581822",
|
||||
"revisions": {
|
||||
"27cc4558b5a3d3387dd11ee2df7a117e7e581822": {
|
||||
"kind": "REWORK",
|
||||
"_number": 2,
|
||||
"ref": "refs/changes/99/4799/2",
|
||||
"fetch": {
|
||||
@@ -4974,6 +4981,8 @@ link:#list-changes[Query Changes].
|
||||
|===========================
|
||||
|Field Name ||Description
|
||||
|`draft` |not set if `false`|Whether the patch set is a draft.
|
||||
|`kind` ||The change kind. Valid values are `REWORK`, `TRIVIAL_REBASE`,
|
||||
`MERGE_FIRST_PARENT_UPDATE`, `NO_CODE_CHANGE`, and `NO_CHANGE`.
|
||||
|`_number` ||The patch set number.
|
||||
|`created` ||
|
||||
The link:rest-api.html#timestamp[timestamp] of when the patch set was
|
||||
|
@@ -14,12 +14,15 @@
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
|
||||
public class RevisionInfo {
|
||||
public transient boolean isCurrent;
|
||||
public Boolean draft;
|
||||
public ChangeKind kind;
|
||||
public int _number;
|
||||
public Timestamp created;
|
||||
public AccountInfo uploader;
|
||||
|
@@ -163,6 +163,7 @@ public class ChangeJson {
|
||||
private final GpgApiAdapter gpgApi;
|
||||
private final ChangeNotes.Factory notesFactory;
|
||||
private final ChangeResource.Factory changeResourceFactory;
|
||||
private final ChangeKindCache changeKindCache;
|
||||
|
||||
private AccountLoader accountLoader;
|
||||
private Map<Change.Id, List<SubmitRecord>> submitRecords;
|
||||
@@ -190,6 +191,7 @@ public class ChangeJson {
|
||||
GpgApiAdapter gpgApi,
|
||||
ChangeNotes.Factory notesFactory,
|
||||
ChangeResource.Factory changeResourceFactory,
|
||||
ChangeKindCache changeKindCache,
|
||||
@Assisted Set<ListChangesOption> options) {
|
||||
this.db = db;
|
||||
this.labelNormalizer = ln;
|
||||
@@ -211,6 +213,7 @@ public class ChangeJson {
|
||||
this.gpgApi = gpgApi;
|
||||
this.notesFactory = notesFactory;
|
||||
this.changeResourceFactory = changeResourceFactory;
|
||||
this.changeKindCache = changeKindCache;
|
||||
this.options = options.isEmpty()
|
||||
? EnumSet.noneOf(ListChangesOption.class)
|
||||
: EnumSet.copyOf(options);
|
||||
@@ -472,7 +475,7 @@ public class ChangeJson {
|
||||
finish(out);
|
||||
|
||||
if (needRevisions) {
|
||||
out.revisions = revisions(ctl, src);
|
||||
out.revisions = revisions(ctl, cd, src);
|
||||
if (out.revisions != null) {
|
||||
for (Map.Entry<String, RevisionInfo> entry : out.revisions.entrySet()) {
|
||||
if (entry.getValue().isCurrent) {
|
||||
@@ -887,7 +890,7 @@ public class ChangeJson {
|
||||
.toSortedList(AccountInfoComparator.ORDER_NULLS_FIRST);
|
||||
}
|
||||
|
||||
private Map<String, RevisionInfo> revisions(ChangeControl ctl,
|
||||
private Map<String, RevisionInfo> revisions(ChangeControl ctl, ChangeData cd,
|
||||
Map<PatchSet.Id, PatchSet> map) throws PatchListNotAvailableException,
|
||||
GpgException, OrmException, IOException {
|
||||
Map<String, RevisionInfo> res = new LinkedHashMap<>();
|
||||
@@ -897,7 +900,7 @@ public class ChangeJson {
|
||||
if ((has(ALL_REVISIONS)
|
||||
|| in.getId().equals(ctl.getChange().currentPatchSetId()))
|
||||
&& ctl.isPatchVisible(in, db.get())) {
|
||||
res.put(in.getRevision().get(), toRevisionInfo(ctl, in, repo));
|
||||
res.put(in.getRevision().get(), toRevisionInfo(ctl, cd, in, repo));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@@ -938,13 +941,15 @@ public class ChangeJson {
|
||||
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||
try (Repository repo =
|
||||
repoManager.openRepository(ctl.getProject().getNameKey())) {
|
||||
RevisionInfo rev = toRevisionInfo(ctl, in, repo);
|
||||
RevisionInfo rev = toRevisionInfo(
|
||||
ctl, changeDataFactory.create(db.get(), ctl), in, repo);
|
||||
accountLoader.fill();
|
||||
return rev;
|
||||
}
|
||||
}
|
||||
|
||||
private RevisionInfo toRevisionInfo(ChangeControl ctl, PatchSet in, Repository repo)
|
||||
private RevisionInfo toRevisionInfo(ChangeControl ctl, ChangeData cd,
|
||||
PatchSet in, Repository repo)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException,
|
||||
IOException {
|
||||
Change c = ctl.getChange();
|
||||
@@ -956,6 +961,7 @@ public class ChangeJson {
|
||||
out.uploader = accountLoader.get(in.getUploader());
|
||||
out.draft = in.isDraft() ? true : null;
|
||||
out.fetch = makeFetchMap(ctl, in);
|
||||
out.kind = changeKindCache.getChangeKind(repo, cd, in);
|
||||
|
||||
boolean setCommit = has(ALL_COMMITS)
|
||||
|| (out.isCurrent && has(CURRENT_COMMIT));
|
||||
|
Reference in New Issue
Block a user