Raise exception if edited commit message is same as current
If the user edits the commit message in the Web UI, but the new commit message is the same as the old one, a new patch set is still created. Add a check in the commit message edit service and throw an exception if called with an unchanged commit message. Now, it will still be possible for the user to submit from the editor with an unchanged commit message, but doing so will result in an error dialog being displayed and no new patch set will be created. Change-Id: Iec13e19a3c7d9b4ce9705869203a719f8c977fda
This commit is contained in:
@@ -328,12 +328,14 @@ public class ChangeUtil {
|
||||
try {
|
||||
final RevWalk revWalk = new RevWalk(git);
|
||||
try {
|
||||
Date now = myIdent.getWhen();
|
||||
Change change = db.changes().get(changeId);
|
||||
|
||||
RevCommit commit =
|
||||
revWalk.parseCommit(ObjectId.fromString(patch.getRevision().get()));
|
||||
if (commit.getFullMessage().equals(message)) {
|
||||
throw new InvalidChangeOperationException("New commit message cannot be same as existing commit message");
|
||||
}
|
||||
|
||||
Date now = myIdent.getWhen();
|
||||
Change change = db.changes().get(changeId);
|
||||
PersonIdent authorIdent =
|
||||
user.newCommitterIdent(now, myIdent.getTimeZone());
|
||||
|
||||
|
Reference in New Issue
Block a user