Move ChangeUtil#getMessage method into GetContent

GetContent is the only caller of this method. Having this method moved
out of ChangeUtil will allow us to make ChangeUtil just be a
collection of static methods once Revert is converted to use
BatchUpdate.

Change-Id: I577249644032bde7d51446e48194de13464212fa
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-02-10 10:55:13 +01:00
parent 1d23e4f717
commit 03549cf82c
2 changed files with 41 additions and 27 deletions

View File

@@ -31,7 +31,6 @@ import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.UpdateException;
import com.google.gerrit.server.git.validators.CommitValidators;
import com.google.gerrit.server.mail.RevertedSender;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.NoSuchChangeException;
@@ -284,26 +283,6 @@ public class ChangeUtil {
}
}
public String getMessage(ChangeNotes notes)
throws NoSuchChangeException, OrmException,
MissingObjectException, IncorrectObjectTypeException, IOException {
Change.Id changeId = notes.getChangeId();
PatchSet ps = psUtil.current(db.get(), notes);
if (ps == null) {
throw new NoSuchChangeException(changeId);
}
try (Repository git =
gitManager.openRepository(notes.getProjectName());
RevWalk revWalk = new RevWalk(git)) {
RevCommit commit = revWalk.parseCommit(
ObjectId.fromString(ps.getRevision().get()));
return commit.getFullMessage();
} catch (RepositoryNotFoundException e) {
throw new NoSuchChangeException(changeId, e);
}
}
public static PatchSet.Id nextPatchSetId(PatchSet.Id id) {
return new PatchSet.Id(id.getParentKey(), id.get() + 1);
}