Search in sources :

Example 1 with MergeUtil

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);
}
Also used : MergeUtil(com.google.gerrit.server.git.MergeUtil) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 MergeUtil (com.google.gerrit.server.git.MergeUtil)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1