Set uploader to current user in "patchset-created" event upon cherry-picking
When using the web ui (both old and new ChangeScreen) to cherry-pick a
change to a branch that already has this change (e.g.: cherry-picking
on the same branch to get rid of dependencies), the corresponding
patchset-created event had its patchSet.uploader set to the Change's
owner instead of the current user. We now set it to the current user,
so stream-events consumers can properly detect who uploaded the
rebased patch set.
Change-Id: I0613ecae06b7843b8ca0294f83378c3917c26810
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java
index bf848a6..a5c7c69 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java
@@ -175,7 +175,7 @@
// The change key exists on the destination branch. The cherry pick
// will be added as a new patch set.
return insertPatchSet(git, revWalk, destChanges.get(0), patchSetId,
- cherryPickCommit, refControl);
+ cherryPickCommit, refControl, currentUser);
} else {
// Change key not found on destination branch. We can create a new
// change.
@@ -192,8 +192,9 @@
private Change.Id insertPatchSet(Repository git, RevWalk revWalk, Change change,
PatchSet.Id patchSetId, RevCommit cherryPickCommit,
- RefControl refControl) throws InvalidChangeOperationException,
- IOException, OrmException, NoSuchChangeException {
+ RefControl refControl, IdentifiedUser uploader)
+ throws InvalidChangeOperationException, IOException, OrmException,
+ NoSuchChangeException {
final PatchSetInserter inserter = patchSetInserterFactory
.create(git, revWalk, refControl, currentUser, change, cherryPickCommit);
final PatchSet.Id newPatchSetId = inserter.getPatchSetId();
@@ -201,6 +202,7 @@
inserter
.setMessage("Uploaded patch set " + newPatchSetId.get() + ".")
.setDraft(current.isDraft())
+ .setUploader(uploader.getAccountId())
.insert();
return change.getId();
}