Implement MatchAuthorToCommitterDate for applicable strategies

Bug: https://crbug.com/732968
Change-Id: I0408d3c871d9120855c180d849cafc791f872b23
This commit is contained in:
Patrick Hiesel
2017-06-22 15:34:53 +02:00
parent 5a31635f30
commit a573bd72e6
5 changed files with 58 additions and 2 deletions

View File

@@ -248,6 +248,7 @@ public class MergeUtil {
mergeCommit.setAuthor(originalCommit.getAuthorIdent());
mergeCommit.setCommitter(cherryPickCommitterIdent);
mergeCommit.setMessage(commitMsg);
matchAuthorToCommitterDate(project, mergeCommit);
return rw.parseCommit(inserter.insert(mergeCommit));
}
throw new MergeConflictException("merge conflict");
@@ -857,4 +858,14 @@ public class MergeUtil {
throw new ResourceNotFoundException(e.getMessage());
}
}
private static void matchAuthorToCommitterDate(ProjectState project, CommitBuilder commit) {
if (project.isMatchAuthorToCommitterDate()) {
commit.setAuthor(
new PersonIdent(
commit.getAuthor(),
commit.getCommitter().getWhen(),
commit.getCommitter().getTimeZone()));
}
}
}

View File

@@ -28,7 +28,8 @@ class MergeOneOp extends SubmitStrategyOp {
@Override
public void updateRepoImpl(RepoContext ctx) throws IntegrationException, IOException {
PersonIdent caller =
ctx.getIdentifiedUser().newCommitterIdent(ctx.getWhen(), ctx.getTimeZone());
ctx.getIdentifiedUser()
.newCommitterIdent(args.serverIdent.getWhen(), args.serverIdent.getTimeZone());
if (args.mergeTip.getCurrentTip() == null) {
throw new IllegalStateException(
"cannot merge commit "

View File

@@ -179,7 +179,8 @@ public class RebaseSubmitStrategy extends SubmitStrategy {
.setDetailedCommitMessage(rebaseAlways)
// Do not post message after inserting new patchset because there
// will be one about change being merged already.
.setPostMessage(false);
.setPostMessage(false)
.setMatchAuthorToCommitterDate(args.project.isMatchAuthorToCommitterDate());
try {
rebaseOp.updateRepo(ctx);
} catch (MergeConflictException | NoSuchChangeException e) {