Merge changes from topic 'author-commiter-timestamp'
* changes: Implement MatchAuthorToCommitterDate for applicable strategies Add option to match author timestamp and committed timestamp
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
|
||||
private static final String PROJECT = "project";
|
||||
private static final String KEY_DESCRIPTION = "description";
|
||||
private static final String KEY_MATCH_AUTHOR_DATE_WITH_COMMITTER_DATE =
|
||||
"matchAuthorToCommitterDate";
|
||||
|
||||
public static final String ACCESS = "access";
|
||||
private static final String KEY_INHERIT_FROM = "inheritFrom";
|
||||
@@ -532,6 +534,13 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
|
||||
p.setSubmitType(getEnum(rc, SUBMIT, null, KEY_ACTION, DEFAULT_SUBMIT_ACTION));
|
||||
p.setUseContentMerge(getEnum(rc, SUBMIT, null, KEY_MERGE_CONTENT, InheritableBoolean.INHERIT));
|
||||
p.setMatchAuthorToCommitterDate(
|
||||
getEnum(
|
||||
rc,
|
||||
SUBMIT,
|
||||
null,
|
||||
KEY_MATCH_AUTHOR_DATE_WITH_COMMITTER_DATE,
|
||||
InheritableBoolean.INHERIT));
|
||||
p.setState(getEnum(rc, PROJECT, null, KEY_STATE, DEFAULT_STATE_VALUE));
|
||||
|
||||
p.setDefaultDashboard(rc.getString(DASHBOARD, null, KEY_DEFAULT));
|
||||
@@ -1036,7 +1045,6 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
rc.unset(PROJECT, null, KEY_DESCRIPTION);
|
||||
}
|
||||
set(rc, ACCESS, null, KEY_INHERIT_FROM, p.getParentName());
|
||||
|
||||
set(
|
||||
rc,
|
||||
RECEIVE,
|
||||
@@ -1102,6 +1110,13 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
|
||||
set(rc, SUBMIT, null, KEY_ACTION, p.getSubmitType(), DEFAULT_SUBMIT_ACTION);
|
||||
set(rc, SUBMIT, null, KEY_MERGE_CONTENT, p.getUseContentMerge(), InheritableBoolean.INHERIT);
|
||||
set(
|
||||
rc,
|
||||
SUBMIT,
|
||||
null,
|
||||
KEY_MATCH_AUTHOR_DATE_WITH_COMMITTER_DATE,
|
||||
p.getMatchAuthorToCommitterDate(),
|
||||
InheritableBoolean.INHERIT);
|
||||
|
||||
set(rc, PROJECT, null, KEY_STATE, p.getState(), DEFAULT_STATE_VALUE);
|
||||
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user