From 340e895d27978fa431c80bd7e63838b63fd895b8 Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Mon, 11 Jan 2016 14:45:14 +0000 Subject: [PATCH] Fix: Make PatchSetInserter set patch set id Edits via the web interface don't set the patch set id in the ChangeUpdate, so edits made via the web have the wrong patch set id set in notedb. This can be observed by submitting a commit message update via the usual cli interface, then submitting a subsequent commit message update via the web interface. The cli update increments the id in the Patch-set trailer, while the update made via the web interface does not: commit message update to patch set 1 via cli, Patch-set trailer incremented to 2. commit 467ad806b7caf92e43759872a0419e1e20769372 Author: Richard Ipsum <1000000@gerrit> Date: Mon Jan 11 12:22:22 2016 +0000 Update patch set 2 Uploaded patch set 2: Commit message was updated. Patch-set: 2 subsequent commit message update to patch set 2 via web interface, Patch-set trailer not incremented (should be incremented to 3) commit 1f05ebe246a23f9b8a8826c27513900301451caf Author: Richard Ipsum <1000000@gerrit> Date: Mon Jan 11 12:23:53 2016 +0000 Update patch set 2 Patch set 3: Commit message was updated. Patch-set: 2 Change-Id: Ic9101e7ac1d0d181c463404976391d7d7271fa34 --- .../com/google/gerrit/server/change/PatchSetInserter.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PatchSetInserter.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PatchSetInserter.java index 8628316322..be3198e3d2 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PatchSetInserter.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PatchSetInserter.java @@ -44,6 +44,7 @@ import com.google.gerrit.server.git.GroupCollector; import com.google.gerrit.server.git.validators.CommitValidationException; import com.google.gerrit.server.git.validators.CommitValidators; import com.google.gerrit.server.mail.ReplacePatchSetSender; +import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.ReviewerStateInternal; import com.google.gerrit.server.patch.PatchSetInfoFactory; import com.google.gerrit.server.project.ChangeControl; @@ -210,6 +211,8 @@ public class PatchSetInserter extends BatchUpdate.Op { ChangeControl ctl = ctx.getChangeControl(); change = ctx.getChange(); + ChangeUpdate update = ctx.getChangeUpdate(); + Change.Id id = change.getId(); final PatchSet.Id currentPatchSetId = change.currentPatchSetId(); if (!change.getStatus().isOpen() && !allowClosed) { @@ -223,6 +226,8 @@ public class PatchSetInserter extends BatchUpdate.Op { patchSet.setRevision(new RevId(commit.name())); patchSet.setDraft(draft); + update.setPatchSetId(patchSet.getId()); + if (groups != null) { patchSet.setGroups(groups); } else {