Do not commit empty merges

This commit is contained in:
René Pfeuffer
2018-12-05 16:09:38 +01:00
parent 9a3b8c26fb
commit 35f73cdc18
2 changed files with 31 additions and 4 deletions

View File

@@ -116,10 +116,12 @@ public class GitMergeCommand extends AbstractGitCommand implements MergeCommand
logger.debug("merged branch {} into {}", toMerge, target);
Person authorToUse = determineAuthor();
try {
clone.commit()
.setAuthor(authorToUse.getName(), authorToUse.getMail())
.setMessage(MessageFormat.format(determineMessageTemplate(), toMerge, target))
.call();
if (!clone.status().call().isClean()) {
clone.commit()
.setAuthor(authorToUse.getName(), authorToUse.getMail())
.setMessage(MessageFormat.format(determineMessageTemplate(), toMerge, target))
.call();
}
} catch (GitAPIException e) {
throw new InternalRepositoryException(context.getRepository(), "could not commit merge between branch " + toMerge + " and " + target, e);
}