Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.ListBranchCommand


  private void list() throws Exception {
    Ref head = db.getRef(Constants.HEAD);
    // This can happen if HEAD is stillborn
    if (head != null) {
      String current = head.getLeaf().getName();
      ListBranchCommand command = new Git(db).branchList();
      if (all)
        command.setListMode(ListMode.ALL);
      else if (remote)
        command.setListMode(ListMode.REMOTE);

      if (containsCommitish != null)
        command.setContains(containsCommitish);

      List<Ref> refs = command.call();
      for (Ref ref : refs) {
        if (ref.getName().equals(Constants.HEAD))
          addRef("(no branch)", head); //$NON-NLS-1$
      }
View Full Code Here


    @Test
    public void shouldGetBranchesWithLocalMode() throws Exception {
        // print = true;
        ListMode mode = null;
        ListBranchCommand command = git.branchList();
        command.setListMode(mode);
        for (Ref ref : command.call()) {
            String fullName = ref.getName();
            String name = fullName.replaceFirst("refs/heads/", "");
            print(fullName + " \t--> " + name);
        }
    }
View Full Code Here

    @Test
    public void shouldGetBranchesWithAllMode() throws Exception {
        // print = true;
        ListMode mode = ListMode.ALL;
        ListBranchCommand command = git.branchList();
        command.setListMode(mode);
        for (Ref ref : command.call()) {
            print(ref.getName());
        }
    }
View Full Code Here

                                          CallSpecification spec,
                                          DocumentWriter writer ) throws GitAPIException {
        Set<String> remoteBranchPrefixes = remoteBranchPrefixes();
        if (remoteBranchPrefixes.isEmpty()) {
            // Generate the child references to the LOCAL branches, which will be sorted by name ...
            ListBranchCommand command = git.branchList();
            List<Ref> branches = command.call();
            // Reverse the sort of the branch names, since they might be version numbers ...
            Collections.sort(branches, REVERSE_REF_COMPARATOR);
            for (Ref ref : branches) {
                String name = ref.getName();
                writer.addChild(spec.childId(name), name);
            }
            return;
        }
        // There is at least one REMOTE branch, so generate the child references to the REMOTE branches,
        // which will be sorted by name (by the command)...
        ListBranchCommand command = git.branchList();
        command.setListMode(ListMode.REMOTE);
        List<Ref> branches = command.call();
        // Reverse the sort of the branch names, since they might be version numbers ...
        Collections.sort(branches, REVERSE_REF_COMPARATOR);
        Set<String> uniqueNames = new HashSet<String>();
        for (Ref ref : branches) {
            String name = ref.getName();
View Full Code Here

   }

   public static List<Ref> getBranches(final Git repo) throws JGitInternalException, ConcurrentRefUpdateException,
            InvalidTagNameException, NoHeadException
   {
      ListBranchCommand branchListCommand = repo.branchList();
      List<Ref> branchList = branchListCommand.call();

      return branchList;
   }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.ListBranchCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.