Fill commit field in EventUtil
This unbreaks all the RevisionEvent listeners. Change-Id: I3c6329cd059fab2cb61beea43ba561a9b6e38fcb
This commit is contained in:
@@ -900,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, cd, in, repo));
|
||||
res.put(in.getRevision().get(), toRevisionInfo(ctl, cd, in, repo, false));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@@ -942,14 +942,14 @@ public class ChangeJson {
|
||||
try (Repository repo =
|
||||
repoManager.openRepository(ctl.getProject().getNameKey())) {
|
||||
RevisionInfo rev = toRevisionInfo(
|
||||
ctl, changeDataFactory.create(db.get(), ctl), in, repo);
|
||||
ctl, changeDataFactory.create(db.get(), ctl), in, repo, true);
|
||||
accountLoader.fill();
|
||||
return rev;
|
||||
}
|
||||
}
|
||||
|
||||
private RevisionInfo toRevisionInfo(ChangeControl ctl, ChangeData cd,
|
||||
PatchSet in, Repository repo)
|
||||
PatchSet in, Repository repo, boolean fillCommit)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException,
|
||||
IOException {
|
||||
Change c = ctl.getChange();
|
||||
@@ -973,7 +973,7 @@ public class ChangeJson {
|
||||
RevCommit commit = rw.parseCommit(ObjectId.fromString(rev));
|
||||
rw.parseBody(commit);
|
||||
if (setCommit) {
|
||||
out.commit = toCommit(ctl, rw, commit, has(WEB_LINKS));
|
||||
out.commit = toCommit(ctl, rw, commit, has(WEB_LINKS), fillCommit);
|
||||
}
|
||||
if (addFooters) {
|
||||
out.commitWithFooters = mergeUtilFactory
|
||||
@@ -1010,9 +1010,12 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
CommitInfo toCommit(ChangeControl ctl, RevWalk rw, RevCommit commit,
|
||||
boolean addLinks) throws IOException {
|
||||
boolean addLinks, boolean fillCommit) throws IOException {
|
||||
Project.NameKey project = ctl.getProject().getNameKey();
|
||||
CommitInfo info = new CommitInfo();
|
||||
if (fillCommit) {
|
||||
info.commit = commit.name();
|
||||
}
|
||||
info.parents = new ArrayList<>(commit.getParentCount());
|
||||
info.author = toGitPerson(commit.getAuthorIdent());
|
||||
info.committer = toGitPerson(commit.getCommitterIdent());
|
||||
|
||||
@@ -53,8 +53,7 @@ public class GetCommit implements RestReadView<RevisionResource> {
|
||||
RevCommit commit = rw.parseCommit(ObjectId.fromString(rev));
|
||||
rw.parseBody(commit);
|
||||
CommitInfo info = json.create(ChangeJson.NO_OPTIONS)
|
||||
.toCommit(rsrc.getControl(), rw, commit, addLinks);
|
||||
info.commit = commit.name();
|
||||
.toCommit(rsrc.getControl(), rw, commit, addLinks, true);
|
||||
Response<CommitInfo> r = Response.ok(info);
|
||||
if (rsrc.isCacheable()) {
|
||||
r.caching(CacheControl.PRIVATE(7, TimeUnit.DAYS));
|
||||
|
||||
Reference in New Issue
Block a user