InlineEdit: Add REST endpoint to retrieve commit message

Change-Id: I9017df268614e8035513af173a7067a8aa10fcec
This commit is contained in:
David Ostrovsky
2014-10-28 23:44:27 +01:00
committed by David Pursehouse
parent c967e151a7
commit 3d2c070206
4 changed files with 85 additions and 0 deletions

View File

@@ -450,6 +450,36 @@ public class ChangeUtil {
}
}
public String getMessage(Change change)
throws NoSuchChangeException, OrmException,
MissingObjectException, IncorrectObjectTypeException, IOException {
Change.Id changeId = change.getId();
PatchSet ps = db.get().patchSets().get(change.currentPatchSetId());
if (ps == null) {
throw new NoSuchChangeException(changeId);
}
Repository git;
try {
git = gitManager.openRepository(change.getProject());
} catch (RepositoryNotFoundException e) {
throw new NoSuchChangeException(changeId, e);
}
try {
RevWalk revWalk = new RevWalk(git);
try {
RevCommit commit =
revWalk.parseCommit(ObjectId.fromString(ps.getRevision()
.get()));
return commit.getFullMessage();
} finally {
revWalk.release();
}
} finally {
git.close();
}
}
public void deleteDraftChange(Change change)
throws NoSuchChangeException, OrmException, IOException {
Change.Id changeId = change.getId();