org.eclipse.jgit.lib.Repository.updateRef()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中org.eclipse.jgit.lib.Repository.updateRef方法的一些代码示例,展示了Repository.updateRef的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.updateRef方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Repository
类名称:Repository
方法名:updateRef

Repository.updateRef介绍

[英]Create a command to update, create or delete a ref in this repository.
[中]创建命令以更新、创建或删除此存储库中的引用。

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Create a command to update, create or delete a ref in this repository.
 *
 * @param ref
 *            name of the ref the caller wants to modify.
 * @return an update command. The caller must finish populating this command
 *         and then invoke one of the update methods to actually make a
 *         change.
 * @throws java.io.IOException
 *             a symbolic ref was passed in and could not be resolved back
 *             to the base ref, as the symbolic ref could not be read.
 */
@NonNull
public RefUpdate updateRef(String ref) throws IOException {
  return updateRef(ref, false);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private RefUpdate createRefUpdate(Ref stashRef) throws IOException {
  RefUpdate update = repo.updateRef(R_STASH);
  update.disableRefLog();
  update.setExpectedOldObjectId(stashRef.getObjectId());
  update.setForceUpdate(true);
  return update;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private RefUpdate.Result updateRef(ObjectId newId) throws IOException {
  RefUpdate ru = db.updateRef(REF_NAME);
  ru.setExpectedOldObjectId(commit != null ? commit : ObjectId.zeroId());
  ru.setNewObjectId(newId);
  ru.setRefLogIdent(pending.get(pending.size() - 1).ident);
  ru.setRefLogMessage(JGitText.get().storePushCertReflog, false);
  try (RevWalk rw = new RevWalk(reader)) {
    return ru.update(rw);
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

continue;
String fullName = currentRef.getName();
RefUpdate update = repo.updateRef(fullName);
update.setForceUpdate(true);
Result deleteResult = update.delete();

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

RefUpdate rup = repo.updateRef(headName);
rup.setNewObjectId(aNewHead);
rup.setRefLogMessage("rebase finished: " + headName + " onto " //$NON-NLS-1$ //$NON-NLS-2$
      JGitText.get().updatingHeadFailed);
rup = repo.updateRef(Constants.HEAD);
rup.setRefLogMessage("rebase finished: returning to " + headName, //$NON-NLS-1$
    false);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private void updateHead(StringBuilder refLogMessage, ObjectId newHeadId,
    ObjectId oldHeadID) throws IOException,
    ConcurrentRefUpdateException {
  RefUpdate refUpdate = repo.updateRef(Constants.HEAD);
  refUpdate.setNewObjectId(newHeadId);
  refUpdate.setRefLogMessage(refLogMessage.toString(), false);
  refUpdate.setExpectedOldObjectId(oldHeadID);
  Result rc = refUpdate.update();
  switch (rc) {
  case NEW:
  case FAST_FORWARD:
    return;
  case REJECTED:
  case LOCK_FAILURE:
    throw new ConcurrentRefUpdateException(
        JGitText.get().couldNotLockHEAD, refUpdate.getRef(), rc);
  default:
    throw new JGitInternalException(MessageFormat.format(
        JGitText.get().updatingRefFailed, Constants.HEAD,
        newHeadId.toString(), rc));
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private Ref updateTagRef(ObjectId tagId, RevWalk revWalk,
    String tagName, String newTagToString) throws IOException,
    ConcurrentRefUpdateException, RefAlreadyExistsException {
  String refName = Constants.R_TAGS + tagName;
  RefUpdate tagRef = repo.updateRef(refName);
  tagRef.setNewObjectId(tagId);
  tagRef.setForceUpdate(forceUpdate);
  tagRef.setRefLogMessage("tagged " + name, false); //$NON-NLS-1$
  Result updateResult = tagRef.update(revWalk);
  switch (updateResult) {
  case NEW:
  case FORCED:
    return repo.exactRef(refName);
  case LOCK_FAILURE:
    throw new ConcurrentRefUpdateException(
        JGitText.get().couldNotLockHEAD, tagRef.getRef(),
        updateResult);
  case REJECTED:
    throw new RefAlreadyExistsException(MessageFormat.format(
        JGitText.get().tagAlreadyExists, newTagToString));
  default:
    throw new JGitInternalException(MessageFormat.format(
        JGitText.get().updatingRefFailed, refName, newTagToString,
        updateResult));
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

JGitText.get().cannotDeleteCheckedOutBranch,
              branchName));
RefUpdate update = repo.updateRef(fullName);
update.setRefLogMessage("branch deleted", false); //$NON-NLS-1$
update.setForceUpdate(true);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

final RefUpdate newHead = clonedRepo.updateRef(Constants.HEAD);
  newHead.disableRefLog();
  newHead.link(head.getName());
RefUpdate u = clonedRepo.updateRef(Constants.HEAD, detached);
u.setNewObjectId(commit.getId());
u.forceUpdate();

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent,
    String refLogMessage) throws IOException {
  Ref currentRef = repo.exactRef(Constants.R_STASH);
  RefUpdate refUpdate = repo.updateRef(Constants.R_STASH);
  refUpdate.setNewObjectId(commitId);
  refUpdate.setRefLogIdent(refLogIdent);
  refUpdate.setRefLogMessage(refLogMessage, false);
  refUpdate.setForceRefLog(true);
  if (currentRef != null)
    refUpdate.setExpectedOldObjectId(currentRef.getObjectId());
  else
    refUpdate.setExpectedOldObjectId(ObjectId.zeroId());
  refUpdate.forceUpdate();
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent,
    String refLogMessage) throws IOException {
  if (ref == null)
    return;
  Ref currentRef = repo.findRef(ref);
  RefUpdate refUpdate = repo.updateRef(ref);
  refUpdate.setNewObjectId(commitId);
  refUpdate.setRefLogIdent(refLogIdent);
  refUpdate.setRefLogMessage(refLogMessage, false);
  refUpdate.setForceRefLog(true);
  if (currentRef != null)
    refUpdate.setExpectedOldObjectId(currentRef.getObjectId());
  else
    refUpdate.setExpectedOldObjectId(ObjectId.zeroId());
  refUpdate.forceUpdate();
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

this.forceUpdate = forceUpdate;
if (localName != null && localDb != null) {
  localUpdate = localDb.updateRef(localName);
  localUpdate.setForceUpdate(true);
  localUpdate.setRefLogMessage("push", true); //$NON-NLS-1$

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

RefUpdate updateRef = repo.updateRef(R_HEADS + name);
updateRef.setNewObjectId(startAt);
updateRef.setRefLogMessage(refLogMessage, false);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

co.setName(newCommit.name()).call();
if (headName.startsWith(Constants.R_HEADS)) {
  RefUpdate rup = repo.updateRef(headName);
  rup.setExpectedOldObjectId(oldCommit);
  rup.setNewObjectId(newCommit);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

co.setProgressMonitor(monitor);
co.checkout();
RefUpdate refUpdate = submoduleRepo.updateRef(
    Constants.HEAD, true);
refUpdate.setNewObjectId(commit);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

if (commitId != null) {
  final RefUpdate ru = repo.updateRef(Constants.HEAD);
  ru.setNewObjectId(commitId);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

static void commitNoteMap(Repository r, String ref, RevWalk walk,
    NoteMap map,
    RevCommit notesCommit,
    ObjectInserter inserter,
    String msg)
    throws IOException {
  // commit the note
  CommitBuilder builder = new CommitBuilder();
  builder.setTreeId(map.writeTree(inserter));
  builder.setAuthor(new PersonIdent(r));
  builder.setCommitter(builder.getAuthor());
  builder.setMessage(msg);
  if (notesCommit != null)
    builder.setParentIds(notesCommit);
  ObjectId commit = inserter.insert(builder);
  inserter.flush();
  RefUpdate refUpdate = r.updateRef(ref);
  if (notesCommit != null)
    refUpdate.setExpectedOldObjectId(notesCommit);
  else
    refUpdate.setExpectedOldObjectId(ObjectId.zeroId());
  refUpdate.setNewObjectId(commit);
  refUpdate.update(walk);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

RefUpdate refUpdate = repo.updateRef(Constants.HEAD, true);
refUpdate.setExpectedOldObjectId(head);
refUpdate.setNewObjectId(commit);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
refUpdate.setRefLogMessage("rebase: aborting", false); //$NON-NLS-1$
if (headName.startsWith(Constants.R_REFS)) {

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

boolean detach = getNewSymref() != null
    || (type == Type.DELETE && expTarget != null);
RefUpdate ru = rp.getRepository().updateRef(getRefName(), detach);
if (expTarget != null) {
  if (!ru.getRef().isSymbolic() || !ru.getRef().getTarget()

相关文章

微信公众号

最新文章

更多

Repository类方法