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

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

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

Repository.getFullBranch介绍

[英]Get the name of the reference that HEAD points to.

This is essentially the same as doing:

return exactRef(Constants.HEAD).getTarget().getName()

Except when HEAD is detached, in which case this method returns the current ObjectId in hexadecimal string format.
[中]获取HEAD指向的引用的名称。
这与执行以下操作基本相同:

return exactRef(Constants.HEAD).getTarget().getName()

除非HEAD被分离,在这种情况下,此方法以十六进制字符串格式返回当前ObjectId。

代码示例

代码示例来源:origin: jphp-group/jphp

@Signature
public String getFullBranch() throws IOException {
  return getWrappedObject().getRepository().getFullBranch();
}

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

/**
 * Get the short name of the current branch that {@code HEAD} points to.
 * <p>
 * This is essentially the same as {@link #getFullBranch()}, except the
 * leading prefix {@code refs/heads/} is removed from the reference before
 * it is returned to the caller.
 *
 * @return name of current branch (for example {@code master}), an ObjectId
 *         in hex format if the current branch is detached, or {@code null}
 *         if the repository is corrupt and has no HEAD reference.
 * @throws java.io.IOException
 */
@Nullable
public String getBranch() throws IOException {
  String name = getFullBranch();
  if (name != null)
    return shortenRefName(name);
  return null;
}

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

/**
 * @param parentShell
 * @param repo
 */
public CheckoutDialog(Shell parentShell, Repository repo) {
  super(parentShell, repo, SHOW_LOCAL_BRANCHES | SHOW_REMOTE_BRANCHES
      | SHOW_TAGS | SHOW_REFERENCES | EXPAND_LOCAL_BRANCHES_NODE
      | ALLOW_MULTISELECTION);
  try {
    currentBranch = repo.getFullBranch();
  } catch (IOException e) {
    currentBranch = null;
  }
}

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

return result;
try {
  String currentBranch = repo.getFullBranch();
  if (!force) {

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

/**
 * @param parentShell
 * @param repo
 */
public DeleteBranchDialog(Shell parentShell, Repository repo) {
  super(parentShell, repo, SHOW_LOCAL_BRANCHES
      | EXPAND_LOCAL_BRANCHES_NODE | SHOW_REMOTE_BRANCHES
      | ALLOW_MULTISELECTION);
  try {
    currentBranch = repo.getFullBranch();
  } catch (IOException e) {
    // just ignore here
  }
}

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

fullOldName = ref.getName();
} else {
  fullOldName = repo.getFullBranch();
  if (fullOldName == null) {
    throw new NoHeadException(

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

protected boolean isLocalBranchCheckedout(Repository repository) {
  try {
    return repository.getFullBranch().startsWith(Constants.R_HEADS);
  } catch (Exception e) {
    // do nothing
  }
  return false;
}

代码示例来源:origin: jgitver/jgitver

public static boolean isDetachedHead(Repository repository) throws IOException {
  return repository.getFullBranch().matches("[0-9a-f]{40}");
}

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

private String getFullBranch(Repository repository)
      throws ExecutionException {
    try {
      return repository.getFullBranch();
    } catch (IOException e) {
      throw new ExecutionException(
          UIText.RebaseCurrentRefCommand_ErrorGettingCurrentBranchMessage,
          e);
    }
  }
}

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

protected List<Ref> getBranchesOfCommit(GitHistoryPage page,
    final Repository repo, boolean hideCurrentBranch)
    throws IOException {
  String head = repo.getFullBranch();
  return getBranchesOfCommit(page, head, hideCurrentBranch);
}

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

@Override
protected void refNameSelected(String refName) {
  boolean tagSelected = refName != null
      && refName.startsWith(Constants.R_TAGS);
  boolean branchSelected = refName != null
      && (refName.startsWith(Constants.R_HEADS) || refName
          .startsWith(Constants.R_REMOTES));
  boolean currentSelected;
  try {
    currentSelected = refName != null
        && refName.equals(repo.getFullBranch());
  } catch (IOException e) {
    currentSelected = false;
  }
  getButton(Window.OK).setEnabled(
      !currentSelected && (branchSelected || tagSelected));
}

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

String fullBranch = repo.getFullBranch();
if (fullBranch != null
    && fullBranch.startsWith(Constants.R_HEADS)) {

代码示例来源:origin: vackosar/gitflow-incremental-builder

private void checkout() throws IOException, GitAPIException {
  if (! (HEAD.equals(configuration.baseBranch) || configuration.baseBranch.startsWith("worktrees/")) && ! git.getRepository().getFullBranch().equals(configuration.baseBranch)) {
    logger.info("Checking out base branch " + configuration.baseBranch + "...");
    git.checkout().setName(configuration.baseBranch).call();
  }
}

代码示例来源:origin: com.beijunyi.parallelgit/parallelgit-utils

private static boolean prepareDeleteBranch(@Nonnull String refName, @Nonnull Repository repo) throws IOException {
 boolean branchExists = branchExists(refName, repo);
 if(refName.equals(repo.getFullBranch())) {
  if(branchExists)
   RepositoryUtils.detachRepositoryHead(repo, repo.resolve(refName));
  else
   return false;
 } else if(!branchExists)
  throw new NoSuchBranchException(refName);
 return true;
}

代码示例来源:origin: beijunyi/ParallelGit

private static boolean prepareDeleteBranch(String refName, Repository repo) throws IOException {
 boolean branchExists = branchExists(refName, repo);
 if(refName.equals(repo.getFullBranch())) {
  if(branchExists)
   RepositoryUtils.detachRepositoryHead(repo, repo.resolve(refName));
  else
   return false;
 } else if(!branchExists)
  throw new NoSuchBranchException(refName);
 return true;
}

代码示例来源:origin: maks/MGit

public String getBranchName() {
  try {
    return getGit().getRepository().getFullBranch();
  } catch (IOException|StopTaskException e) {
    Timber.e(e, "error getting branch name");
  }
  return "";
}

代码示例来源:origin: sheimi/SGit

public String getBranchName() {
  try {
    return getGit().getRepository().getFullBranch();
  } catch (IOException e) {
    BasicFunctions.showException(e);
  } catch (StopTaskException e) {
  }
  return "";
}

代码示例来源:origin: com.beijunyi/parallelgit-utils

private static boolean prepareDeleteBranch(String refName, Repository repo) throws IOException {
 boolean branchExists = branchExists(refName, repo);
 if(refName.equals(repo.getFullBranch())) {
  if(branchExists)
   RepositoryUtils.detachRepositoryHead(repo, repo.resolve(refName));
  else
   return false;
 } else if(!branchExists)
  throw new NoSuchBranchException(refName);
 return true;
}

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

private void detachHead() throws IOException {
  final String head = db.getFullBranch();
  final ObjectId id = db.resolve(Constants.HEAD);
  if (!ObjectId.isId(head) && id != null) {
    final LockFile lf;
    lf = new LockFile(new File(db.getDirectory(), Constants.HEAD), db.getFS());
    if (!lf.lock())
      throw new IOException(MessageFormat.format(CLIText.get().cannotLock, Constants.HEAD));
    lf.write(id);
    if (!lf.commit())
      throw new IOException(CLIText.get().cannotDeatchHEAD);
  }
}

代码示例来源:origin: FlareBot/FlareBot

public static RevCommit getLatestCommit() {
  if (git != null && latestCommit == null) {
    if (getRepository() != null) {
      try (RevWalk walk = new RevWalk(getRepository())) {
        Ref head = getRepository().exactRef(getRepository().getFullBranch());
        GitHandler.latestCommit = walk.parseCommit(head.getObjectId());
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
  return latestCommit;
}

相关文章

Repository类方法