aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2019-06-24 11:02:08 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2019-06-25 14:38:37 +0000
commit8da2a12a9cb4ebaf66607543e9a2379706e59d3d (patch)
treee6912f54724c52c6823e620d3f0413ee4385a4e6
parent737271991a867c1b1f0865eea6794ec17a97bfbd (diff)
Set commit date to cherry-pick time
When we stage commits, we expect them to have the commit date of the staging time. Move the timestamp variable down, since it's only used later and this makes things less confusing for future readers I hope. Fixes: QTQAINFRA-2994 Fixes: QTQAINFRA-3019 Change-Id: If22cdda9b05d1d453981ada8459031eea95ea844 Reviewed-by: Jukka Jokiniva <jukka.jokiniva@qt.io> Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io>
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java
index 0169885..061d341 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java
@@ -39,6 +39,7 @@ import com.google.inject.Singleton;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.Arrays;
+import java.util.Date;
import java.util.List;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.ObjectId;
@@ -110,8 +111,8 @@ public class QtCherryPickPatch {
return commitToCherryPick;
}
- Timestamp now = TimeUtil.nowTs();
- PersonIdent committerIdent = commitToCherryPick.getCommitterIdent();
+ // Copy the committer, but change the date to now.
+ PersonIdent committerIdent = new PersonIdent(commitToCherryPick.getCommitterIdent(), new Date());
commitToCherryPick.setPatchsetId(changeData.currentPatchSet().getId());
commitToCherryPick.setNotes(changeData.notes());
@@ -136,7 +137,6 @@ public class QtCherryPickPatch {
cherryPickCommit = revWalk.parseCommit(commit);
} else {
String commitMessage = mergeUtil.createCommitMessageOnSubmit(commitToCherryPick, baseCommit);
- commitMessage += " "; // This ensures unique SHA1 is generated, otherwise old is reused
cherryPickCommit = mergeUtil.createCherryPickFromCommit(oi,
git.getConfig(),
baseCommit,
@@ -154,7 +154,8 @@ public class QtCherryPickPatch {
logger.atInfo().log("qtcodereview: new patch %s -> %s", commitToCherryPick, cherryPickCommit);
oi.flush();
}
- BatchUpdate bu = batchUpdateFactory.create(dbProvider.get(), project, identifiedUser, now);
+ Timestamp commitTimestamp = new Timestamp(committerIdent.getWhen().getTime());
+ BatchUpdate bu = batchUpdateFactory.create(dbProvider.get(), project, identifiedUser, commitTimestamp);
bu.setRepository(git, revWalk, oi);
if (!patchSetNotChanged && !mergeCommit) {
Change.Id changeId = insertPatchSet(bu, git, changeData.notes(), cherryPickCommit);