当前位置: 首页>>代码示例>>Java>>正文


Java CommitBuilder.setParentIds方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.CommitBuilder.setParentIds方法的典型用法代码示例。如果您正苦于以下问题:Java CommitBuilder.setParentIds方法的具体用法?Java CommitBuilder.setParentIds怎么用?Java CommitBuilder.setParentIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.CommitBuilder的用法示例。


在下文中一共展示了CommitBuilder.setParentIds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private ObjectId createCommit(
    Repository repository,
    RevCommit basePatchSetCommit,
    ObjectId tree,
    String commitMessage,
    Timestamp timestamp)
    throws IOException {
  try (ObjectInserter objectInserter = repository.newObjectInserter()) {
    CommitBuilder builder = new CommitBuilder();
    builder.setTreeId(tree);
    builder.setParentIds(basePatchSetCommit.getParents());
    builder.setAuthor(basePatchSetCommit.getAuthorIdent());
    builder.setCommitter(getCommitterIdent(timestamp));
    builder.setMessage(commitMessage);
    ObjectId newCommitId = objectInserter.insert(builder);
    objectInserter.flush();
    return newCommitId;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:ChangeEditModifier.java

示例2: createCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private ObjectId createCommit(
    ObjectInserter objectInserter,
    RevCommit basePatchSetCommit,
    String commitMessage,
    Timestamp timestamp)
    throws IOException {
  CommitBuilder builder = new CommitBuilder();
  builder.setTreeId(basePatchSetCommit.getTree());
  builder.setParentIds(basePatchSetCommit.getParents());
  builder.setAuthor(basePatchSetCommit.getAuthorIdent());
  builder.setCommitter(
      currentUserProvider.get().asIdentifiedUser().newCommitterIdent(timestamp, tz));
  builder.setMessage(commitMessage);
  ObjectId newCommitId = objectInserter.insert(builder);
  objectInserter.flush();
  return newCommitId;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:PutMessage.java

示例3: createMergeCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
public ObjectId createMergeCommit(Map<SubtreeConfig, RevCommit> parentCommits, String message)
		throws IOException {
	PersonIdent latestIdent = getLatestPersonIdent(parentCommits.values());
	DirCache treeDirCache = createTreeDirCache(parentCommits, message);
	List<? extends ObjectId> parentIds = new ArrayList<>(parentCommits.values());
	try (ObjectInserter inserter = repository.newObjectInserter()) {
		ObjectId treeId = treeDirCache.writeTree(inserter);

		PersonIdent repositoryUser = new PersonIdent(repository);
		PersonIdent ident = new PersonIdent(repositoryUser, latestIdent.getWhen().getTime(),
				latestIdent.getTimeZoneOffset());
		CommitBuilder commitBuilder = new CommitBuilder();
		commitBuilder.setTreeId(treeId);
		commitBuilder.setAuthor(ident);
		commitBuilder.setCommitter(ident);
		commitBuilder.setMessage(message);
		commitBuilder.setParentIds(parentIds);
		ObjectId mergeCommit = inserter.insert(commitBuilder);
		inserter.flush();
		return mergeCommit;
	}
}
 
开发者ID:robinst,项目名称:git-merge-repos,代码行数:23,代码来源:SubtreeMerger.java

示例4: merge

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
@Nullable
  public static ObjectId merge(Repository repository, ObjectId source, ObjectId target, 
  		boolean squash, PersonIdent committer, String commitMessage) {
  	try (	RevWalk revWalk = new RevWalk(repository);
  			ObjectInserter inserter = repository.newObjectInserter();) {
  		RevCommit sourceCommit = revWalk.parseCommit(source);
  		RevCommit targetCommit = revWalk.parseCommit(target);
  		Merger merger = MergeStrategy.RECURSIVE.newMerger(repository, true);
  		if (merger.merge(targetCommit, sourceCommit)) {
        CommitBuilder mergedCommit = new CommitBuilder();
        mergedCommit.setAuthor(sourceCommit.getAuthorIdent());
        mergedCommit.setCommitter(committer);
        if (squash)
        	mergedCommit.setParentId(targetCommit);
        else
        	mergedCommit.setParentIds(targetCommit, sourceCommit);
        mergedCommit.setMessage(commitMessage);
        mergedCommit.setTreeId(merger.getResultTreeId());
        ObjectId mergedCommitId = inserter.insert(mergedCommit);
        inserter.flush();
        return mergedCommitId;
  		} else {
  			return null;
  		}
  	} catch (IOException e) {
  		throw new RuntimeException(e);
}
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:29,代码来源:GitUtils.java

示例5: createNotesCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
/**
 * Creates a merged notes commit.
 */
private RevCommit createNotesCommit(NoteMap map, ObjectInserter inserter, RevWalk revWalk,
    String message, RevCommit... parents) throws IOException {
  CommitBuilder commitBuilder = new CommitBuilder();
  commitBuilder.setTreeId(map.writeTree(inserter));
  commitBuilder.setAuthor(author);
  commitBuilder.setCommitter(author);
  if (parents.length > 0) {
    commitBuilder.setParentIds(parents);
  }
  commitBuilder.setMessage(message);
  ObjectId commitId = inserter.insert(commitBuilder);
  inserter.flush();
  return revWalk.parseCommit(commitId);
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:18,代码来源:AppraiseGitReviewClient.java

示例6: createCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private RevCommit createCommit(
    NoteMap map, PersonIdent author, String message, RevCommit... parents) throws IOException {
  CommitBuilder b = new CommitBuilder();
  b.setTreeId(map.writeTree(inserter));
  b.setAuthor(author);
  b.setCommitter(author);
  if (parents.length > 0) {
    b.setParentIds(parents);
  }
  b.setMessage(message);
  ObjectId commitId = inserter.insert(b);
  inserter.flush();
  return revWalk.parseCommit(commitId);
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:15,代码来源:GitNoteWriter.java

示例7: createCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private RevCommit createCommit(
    NoteMap map, PersonIdent author, String message, RevCommit... parents) throws IOException {
  CommitBuilder b = new CommitBuilder();
  b.setTreeId(map.writeTree(inserter));
  b.setAuthor(author != null ? author : gerritIdent);
  b.setCommitter(gerritIdent);
  if (parents.length > 0) {
    b.setParentIds(parents);
  }
  b.setMessage(message);
  ObjectId commitId = inserter.insert(b);
  inserter.flush();
  return revWalk.parseCommit(commitId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:NotesBranchUtil.java

示例8: createMergeCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
public static RevCommit createMergeCommit(
    ObjectInserter inserter,
    Config repoConfig,
    RevCommit mergeTip,
    RevCommit originalCommit,
    String mergeStrategy,
    PersonIdent committerIndent,
    String commitMsg,
    RevWalk rw)
    throws IOException, MergeIdenticalTreeException, MergeConflictException {

  if (!MergeStrategy.THEIRS.getName().equals(mergeStrategy)
      && rw.isMergedInto(originalCommit, mergeTip)) {
    throw new ChangeAlreadyMergedException(
        "'" + originalCommit.getName() + "' has already been merged");
  }

  Merger m = newMerger(inserter, repoConfig, mergeStrategy);
  if (m.merge(false, mergeTip, originalCommit)) {
    ObjectId tree = m.getResultTreeId();

    CommitBuilder mergeCommit = new CommitBuilder();
    mergeCommit.setTreeId(tree);
    mergeCommit.setParentIds(mergeTip, originalCommit);
    mergeCommit.setAuthor(committerIndent);
    mergeCommit.setCommitter(committerIndent);
    mergeCommit.setMessage(commitMsg);
    return rw.parseCommit(inserter.insert(mergeCommit));
  }
  List<String> conflicts = ImmutableList.of();
  if (m instanceof ResolveMerger) {
    conflicts = ((ResolveMerger) m).getUnmergedPaths();
  }
  throw new MergeConflictException(createConflictMessage(conflicts));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:36,代码来源:MergeUtil.java

示例9: apply

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
/**
 * Apply this update to the given inserter.
 *
 * @param rw walk for reading back any objects needed for the update.
 * @param ins inserter to write to; callers should not flush.
 * @param curr the current tip of the branch prior to this update.
 * @return commit ID produced by inserting this update's commit, or null if this update is a no-op
 *     and should be skipped. The zero ID is a valid return value, and indicates the ref should be
 *     deleted.
 * @throws OrmException if a Gerrit-level error occurred.
 * @throws IOException if a lower-level error occurred.
 */
final ObjectId apply(RevWalk rw, ObjectInserter ins, ObjectId curr)
    throws OrmException, IOException {
  if (isEmpty()) {
    return null;
  }

  // Allow this method to proceed even if migration.failChangeWrites() = true.
  // This may be used by an auto-rebuilding step that the caller does not plan
  // to actually store.

  checkArgument(rw.getObjectReader().getCreatedFromInserter() == ins);
  checkNotReadOnly();
  ObjectId z = ObjectId.zeroId();
  CommitBuilder cb = applyImpl(rw, ins, curr);
  if (cb == null) {
    result = z;
    return z; // Impl intends to delete the ref.
  } else if (cb == NO_OP_UPDATE) {
    return null; // Impl is a no-op.
  }
  cb.setAuthor(authorIdent);
  cb.setCommitter(new PersonIdent(serverIdent, when));
  if (!curr.equals(z)) {
    cb.setParentId(curr);
  } else {
    cb.setParentIds(); // Ref is currently nonexistent, commit has no parents.
  }
  if (cb.getTreeId() == null) {
    if (curr.equals(z)) {
      cb.setTreeId(emptyTree(ins)); // No parent, assume empty tree.
    } else {
      RevCommit p = rw.parseCommit(curr);
      cb.setTreeId(p.getTree()); // Copy tree from parent.
    }
  }
  result = ins.insert(cb);
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:51,代码来源:AbstractChangeUpdate.java

示例10: composeGitlinksCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
/** Amend an existing commit with gitlink updates */
public CodeReviewCommit composeGitlinksCommit(
    Branch.NameKey subscriber, CodeReviewCommit currentCommit)
    throws IOException, SubmoduleException {
  OpenRepo or;
  try {
    or = orm.getRepo(subscriber.getParentKey());
  } catch (NoSuchProjectException | IOException e) {
    throw new SubmoduleException("Cannot access superproject", e);
  }

  StringBuilder msgbuf = new StringBuilder("");
  DirCache dc = readTree(or.rw, currentCommit);
  DirCacheEditor ed = dc.editor();
  for (SubmoduleSubscription s : targets.get(subscriber)) {
    updateSubmodule(dc, ed, msgbuf, s);
  }
  ed.finish();
  ObjectId newTreeId = dc.writeTree(or.ins);

  // Gitlinks are already updated, just return the commit
  if (newTreeId.equals(currentCommit.getTree())) {
    return currentCommit;
  }
  or.rw.parseBody(currentCommit);
  CommitBuilder commit = new CommitBuilder();
  commit.setTreeId(newTreeId);
  commit.setParentIds(currentCommit.getParents());
  if (verboseSuperProject != VerboseSuperprojectUpdate.FALSE) {
    // TODO(czhen): handle cherrypick footer
    commit.setMessage(currentCommit.getFullMessage() + "\n\n* submodules:\n" + msgbuf.toString());
  } else {
    commit.setMessage(currentCommit.getFullMessage());
  }
  commit.setAuthor(currentCommit.getAuthorIdent());
  commit.setCommitter(myIdent);
  ObjectId id = or.ins.insert(commit);
  CodeReviewCommit newCommit = or.rw.parseCommit(id);
  newCommit.copyFrom(currentCommit);
  return newCommit;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:42,代码来源:SubmoduleOp.java

示例11: writeMergeCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
public CodeReviewCommit writeMergeCommit(
    PersonIdent author,
    PersonIdent committer,
    CodeReviewRevWalk rw,
    ObjectInserter inserter,
    Branch.NameKey destBranch,
    CodeReviewCommit mergeTip,
    ObjectId treeId,
    CodeReviewCommit n)
    throws IOException, MissingObjectException, IncorrectObjectTypeException {
  final List<CodeReviewCommit> merged = new ArrayList<>();
  rw.reset();
  rw.markStart(n);
  rw.markUninteresting(mergeTip);
  CodeReviewCommit crc;
  while ((crc = rw.next()) != null) {
    if (crc.getPatchsetId() != null) {
      merged.add(crc);
    }
  }

  StringBuilder msgbuf = new StringBuilder().append(summarize(rw, merged));
  if (!R_HEADS_MASTER.equals(destBranch.get())) {
    msgbuf.append(" into ");
    msgbuf.append(destBranch.getShortName());
  }

  if (merged.size() > 1) {
    msgbuf.append("\n\n* changes:\n");
    for (CodeReviewCommit c : merged) {
      rw.parseBody(c);
      msgbuf.append("  ");
      msgbuf.append(c.getShortMessage());
      msgbuf.append("\n");
    }
  }

  final CommitBuilder mergeCommit = new CommitBuilder();
  mergeCommit.setTreeId(treeId);
  mergeCommit.setParentIds(mergeTip, n);
  mergeCommit.setAuthor(author);
  mergeCommit.setCommitter(committer);
  mergeCommit.setMessage(msgbuf.toString());

  CodeReviewCommit mergeResult = rw.parseCommit(inserter.insert(mergeCommit));
  mergeResult.setNotes(n.getNotes());
  return mergeResult;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:49,代码来源:MergeUtil.java

示例12: commit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
/** Commits updates to the external IDs. */
public static ObjectId commit(
    Project.NameKey project,
    Repository repo,
    RevWalk rw,
    ObjectInserter ins,
    ObjectId rev,
    NoteMap noteMap,
    String commitMessage,
    PersonIdent committerIdent,
    PersonIdent authorIdent,
    @Nullable IdentifiedUser user,
    GitReferenceUpdated gitRefUpdated)
    throws IOException {
  CommitBuilder cb = new CommitBuilder();
  cb.setMessage(commitMessage);
  cb.setTreeId(noteMap.writeTree(ins));
  cb.setAuthor(authorIdent);
  cb.setCommitter(committerIdent);
  if (!rev.equals(ObjectId.zeroId())) {
    cb.setParentId(rev);
  } else {
    cb.setParentIds(); // Ref is currently nonexistent, commit has no parents.
  }
  if (cb.getTreeId() == null) {
    if (rev.equals(ObjectId.zeroId())) {
      cb.setTreeId(emptyTree(ins)); // No parent, assume empty tree.
    } else {
      RevCommit p = rw.parseCommit(rev);
      cb.setTreeId(p.getTree()); // Copy tree from parent.
    }
  }
  ObjectId commitId = ins.insert(cb);
  ins.flush();

  RefUpdate u = repo.updateRef(RefNames.REFS_EXTERNAL_IDS);
  u.setRefLogIdent(committerIdent);
  u.setRefLogMessage("Update external IDs", false);
  u.setExpectedOldObjectId(rev);
  u.setNewObjectId(commitId);
  RefUpdate.Result res = u.update();
  switch (res) {
    case NEW:
    case FAST_FORWARD:
    case NO_CHANGE:
    case RENAMED:
    case FORCED:
      break;
    case LOCK_FAILURE:
      throw new LockFailureException("Updating external IDs failed with " + res, u);
    case IO_FAILURE:
    case NOT_ATTEMPTED:
    case REJECTED:
    case REJECTED_CURRENT_BRANCH:
    case REJECTED_MISSING_OBJECT:
    case REJECTED_OTHER_REASON:
    default:
      throw new IOException("Updating external IDs failed with " + res);
  }
  gitRefUpdated.fire(project, u, user != null ? user.getAccount() : null);
  return rw.parseCommit(commitId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:63,代码来源:ExternalIdsUpdate.java

示例13: execute

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
public boolean execute() {
    boolean hadEffecitiveCommit = true;
    final PersonIdent author = buildPersonIdent(git,
                                                commitInfo.getName(),
                                                commitInfo.getEmail(),
                                                commitInfo.getTimeZone(),
                                                commitInfo.getWhen());

    try (final ObjectInserter odi = git.getRepository().newObjectInserter()) {
        final ObjectId headId = git.getRepository().resolve(branchName + "^{commit}");

        final Optional<ObjectId> tree;
        if (content instanceof DefaultCommitContent) {
            tree = new CreateDefaultCommitTree(git,
                                               originId,
                                               odi,
                                               (DefaultCommitContent) content).execute();
        } else if (content instanceof MoveCommitContent) {
            tree = new CreateMoveCommitTree(git,
                                            originId,
                                            odi,
                                            (MoveCommitContent) content).execute();
        } else if (content instanceof CopyCommitContent) {
            tree = new CreateCopyCommitTree(git,
                                            originId,
                                            odi,
                                            (CopyCommitContent) content).execute();
        } else if (content instanceof RevertCommitContent) {
            tree = new CreateRevertCommitTree(git,
                                              originId,
                                              odi,
                                              (RevertCommitContent) content).execute();
        } else {
            tree = Optional.empty();
        }

        if (tree.isPresent()) {
            final CommitBuilder commit = new CommitBuilder();
            commit.setAuthor(author);
            commit.setCommitter(author);
            commit.setEncoding(Constants.CHARACTER_ENCODING);
            commit.setMessage(commitInfo.getMessage());
            if (headId != null) {
                if (amend) {
                    final RevCommit previousCommit = git.resolveRevCommit(headId);
                    final List<RevCommit> p = Arrays.asList(previousCommit.getParents());
                    reverse(p);
                    commit.setParentIds(p);
                } else {
                    commit.setParentId(headId);
                }
            }
            commit.setTreeId(tree.get());

            final ObjectId commitId = odi.insert(commit);
            odi.flush();

            git.refUpdate(branchName,
                          git.resolveRevCommit(commitId));
        } else {
            hadEffecitiveCommit = false;
        }
    } catch (final Throwable t) {
        t.printStackTrace();
        throw new RuntimeException(t);
    }
    return hadEffecitiveCommit;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:69,代码来源:Commit.java

示例14: merge

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
public boolean merge(String baseBranchName, IssuePK issuePK, String message, LoginContext loginContext) {
  String mergeMessage = PullRequest.getMergeMessage(issuePK, new PullRequestEndpoint(issuePK.getRepositoryPK(), baseBranchName))
      + "\n\n" + message;
  try (RepositoryReader reader = new RepositoryReader(issuePK.getRepositoryPK())) {
    Repository repository = reader.getRepository();

    String pullBranch = Constants.R_REFS + "pull/" + issuePK.getIssueId() + "/head";
    String baseBranchRefName = Constants.R_HEADS + baseBranchName;

    ThreeWayMerger merger = MergeStrategy.RECURSIVE.newMerger(repository, true);
    ObjectInserter inserter = repository.newObjectInserter();

    try {
      ObjectId baseObjectId = repository.resolve(baseBranchRefName);
      ObjectId pullBranchObjectId = repository.resolve(pullBranch);

      boolean noError = merger.merge(baseObjectId, pullBranchObjectId);
      if (!noError) {
        throw new RuntimeException("cannot merge!!");
      }

      ObjectId resultTreeId = merger.getResultTreeId();

      PersonIdent personIdent = new PersonIdent(loginContext.getName(), loginContext.getEmail());
      CommitBuilder commit = new CommitBuilder();
      commit.setCommitter(personIdent);
      commit.setAuthor(personIdent);
      commit.setMessage(mergeMessage);
      commit.setParentIds(baseObjectId, pullBranchObjectId);
      commit.setTreeId(resultTreeId);
      ObjectId mergedCommitId = inserter.insert(commit);
      inserter.flush();

      RefUpdate refUpdate = repository.updateRef(baseBranchRefName);
      refUpdate.setNewObjectId(mergedCommitId);
      refUpdate.setForceUpdate(false);
      refUpdate.setRefLogIdent(personIdent);
      refUpdate.setRefLogMessage("merged", false);
      refUpdate.update();

      return true;
    } catch (RevisionSyntaxException | IOException e) {
      return false;
    } finally {
      inserter.release();
    }
  }
}
 
开发者ID:kamegu,项目名称:git-webapp,代码行数:49,代码来源:GitOperation.java

示例15: merge

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
/**
 * Tries to merge a commit into a branch. If there are conflicts, the merge will fail.
 * 
 * @param repository
 * @param src
 * @param toBranch
 * @param committer
 * @param message
 * @return the merge result
 */
public static MergeResult merge(Repository repository, String src, String toBranch, PersonIdent committer, String message) {

	if (!toBranch.startsWith(Constants.R_REFS)) {
		// branch ref doesn't start with ref, assume this is a branch head
		toBranch = Constants.R_HEADS + toBranch;
	}

	try (RevWalk revWalk = new RevWalk(repository)) {
		RevCommit branchTip = revWalk.lookupCommit(repository.resolve(toBranch));
		RevCommit srcTip = revWalk.lookupCommit(repository.resolve(src));
		if (revWalk.isMergedInto(srcTip, branchTip)) {
			// already merged
			return new MergeResult(MergeStatus.ALREADY_MERGED, null);
		}
		RecursiveMerger merger = (RecursiveMerger) MergeStrategy.RECURSIVE.newMerger(repository, true);
		boolean merged = merger.merge(branchTip, srcTip);
		if (merged) {
			// create a merge commit and a reference to track the merge commit
			ObjectId treeId = merger.getResultTreeId();
			try (ObjectInserter odi = repository.newObjectInserter()) {
				// Create a commit object
				CommitBuilder commitBuilder = new CommitBuilder();
				commitBuilder.setCommitter(committer);
				commitBuilder.setAuthor(committer);
				commitBuilder.setEncoding(Constants.CHARSET);
				if (StringUtils.isEmpty(message)) {
					message = MessageFormat.format("merge {0} into {1}", srcTip.getName(), branchTip.getName());
				}
				commitBuilder.setMessage(message);
				commitBuilder.setParentIds(branchTip.getId(), srcTip.getId());
				commitBuilder.setTreeId(treeId);

				// Insert the merge commit into the repository
				ObjectId mergeCommitId = odi.insert(commitBuilder);
				odi.flush();

				// set the merge ref to the merge commit
				RevCommit mergeCommit = revWalk.parseCommit(mergeCommitId);
				RefUpdate mergeRefUpdate = repository.updateRef(toBranch);
				mergeRefUpdate.setNewObjectId(mergeCommitId);
				mergeRefUpdate.setRefLogMessage("commit: " + mergeCommit.getShortMessage(), false);
				RefUpdate.Result rc = mergeRefUpdate.update();
				switch (rc) {
				case FAST_FORWARD:
					// successful, clean merge
					break;
				default:
					throw new GitBlitException(MessageFormat.format("Unexpected result \"{0}\" when merging commit {1} into {2} in {3}",
							rc.name(), srcTip.getName(), branchTip.getName(), repository.getDirectory()));
				}

				// return the merge commit id
				return new MergeResult(MergeStatus.MERGED, mergeCommitId.getName());
			}
		}
	} catch (IOException e) {
		LOGGER.error("Failed to merge", e);
	}
	return new MergeResult(MergeStatus.FAILED, null);
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:71,代码来源:JGitUtils.java


注:本文中的org.eclipse.jgit.lib.CommitBuilder.setParentIds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。