use of com.google.gerrit.server.git.MergeUtil in project gerrit by GerritCodeReview.
the class CreateChange method newMergeCommit.
private RevCommit newMergeCommit(Repository repo, ObjectInserter oi, RevWalk rw, ProjectControl projectControl, RevCommit mergeTip, MergeInput merge, PersonIdent authorIdent, String commitMessage) throws RestApiException, IOException {
if (Strings.isNullOrEmpty(merge.source)) {
throw new BadRequestException("merge.source must be non-empty");
}
RevCommit sourceCommit = MergeUtil.resolveCommit(repo, rw, merge.source);
if (!projectControl.canReadCommit(db.get(), repo, sourceCommit)) {
throw new BadRequestException("do not have read permission for: " + merge.source);
}
MergeUtil mergeUtil = mergeUtilFactory.create(projectControl.getProjectState());
// default merge strategy from project settings
String mergeStrategy = MoreObjects.firstNonNull(Strings.emptyToNull(merge.strategy), mergeUtil.mergeStrategyName());
return MergeUtil.createMergeCommit(oi, repo.getConfig(), mergeTip, sourceCommit, mergeStrategy, authorIdent, commitMessage, rw);
}
Aggregations