@Signature public String getFullBranch() throws IOException { return getWrappedObject().getRepository().getFullBranch(); }
/** * 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; }
/** * @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; } }
return result; try { String currentBranch = repo.getFullBranch(); if (!force) {
/** * @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 } }
fullOldName = ref.getName(); } else { fullOldName = repo.getFullBranch(); if (fullOldName == null) { throw new NoHeadException(
protected boolean isLocalBranchCheckedout(Repository repository) { try { return repository.getFullBranch().startsWith(Constants.R_HEADS); } catch (Exception e) { // do nothing } return false; }
public static boolean isDetachedHead(Repository repository) throws IOException { return repository.getFullBranch().matches("[0-9a-f]{40}"); }
private String getFullBranch(Repository repository) throws ExecutionException { try { return repository.getFullBranch(); } catch (IOException e) { throw new ExecutionException( UIText.RebaseCurrentRefCommand_ErrorGettingCurrentBranchMessage, e); } } }
protected List<Ref> getBranchesOfCommit(GitHistoryPage page, final Repository repo, boolean hideCurrentBranch) throws IOException { String head = repo.getFullBranch(); return getBranchesOfCommit(page, head, hideCurrentBranch); }
@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)); }
String fullBranch = repo.getFullBranch(); if (fullBranch != null && fullBranch.startsWith(Constants.R_HEADS)) {
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(); } }
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; }
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; }
public String getBranchName() { try { return getGit().getRepository().getFullBranch(); } catch (IOException|StopTaskException e) { Timber.e(e, "error getting branch name"); } return ""; }
public String getBranchName() { try { return getGit().getRepository().getFullBranch(); } catch (IOException e) { BasicFunctions.showException(e); } catch (StopTaskException e) { } return ""; }
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; }
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); } }
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; }