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


Java ListBranchCommand类代码示例

本文整理汇总了Java中org.eclipse.jgit.api.ListBranchCommand的典型用法代码示例。如果您正苦于以下问题:Java ListBranchCommand类的具体用法?Java ListBranchCommand怎么用?Java ListBranchCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getBranches

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
public static ArrayList<String> getBranches(final File repo) {
    try {
        final List<Ref> refs = Git.open(repo)
                .branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call();

        final ArrayList<String> result = new ArrayList<>();
        for (Ref ref : refs)
            result.add(ref.getName());

        return result;
    } catch (GitAPIException | IOException e) {
        e.printStackTrace();
    }

    return new ArrayList<>();
}
 
开发者ID:LonamiWebs,项目名称:Stringlate,代码行数:17,代码来源:GitWrapper.java

示例2: gitClone

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
/**
 * Clone GIT repository from sourceforge.
 *
 * @param gitDirectory The directory of Git.
 */
private void gitClone(File gitDirectory) {
    try {
        git = Git.cloneRepository()
                .setDirectory(gitDirectory)
                .setURI("http://git.code.sf.net/p/neembuuuploader/gitcode")
                .setProgressMonitor(new TextProgressMonitor()).call();

        for (Ref f : git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call()) {
            git.checkout().setName(f.getName()).call();
            System.out.println("checked out branch " + f.getName()
                    + ". HEAD: " + git.getRepository().getRef("HEAD"));
        }
        // try to checkout branches by specifying abbreviated names
        git.checkout().setName("master").call();
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:Neembuu-Uploader,项目名称:neembuu-uploader,代码行数:24,代码来源:UpdaterGenerator.java

示例3: gitClone

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
/**
 * Clone GIT repository from sourceforge.
 *
 * @param gitDirectory The directory of Git.
 */
private void gitClone(File gitDirectory) {
    try {
        git = Git.cloneRepository()
                .setDirectory(gitDirectory)
                .setURI(env.gitURI())
                //.setURI("http://git.code.sf.net/p/neembuuuploader/gitcode")
                .setProgressMonitor(new TextProgressMonitor()).call();

        for (Ref f : git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call()) {
            git.checkout().setName(f.getName()).call();
            System.out.println("checked out branch " + f.getName()
                    + ". HEAD: " + git.getRepository().getRef("HEAD"));
        }
        // try to checkout branches by specifying abbreviated names
        git.checkout().setName("master").call();
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:Neembuu-Uploader,项目名称:neembuu-uploader,代码行数:25,代码来源:UpdaterGenerator.java

示例4: findBranches

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
List<GitBranch> findBranches() throws IOException {
    Repository repository = getRepository();

    List<GitBranch> result = new LinkedList<>();
    try (Git git = new Git(repository)) {
        List<Ref> branches = git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call();
        for (Ref branchRef : branches) {
            GitBranch newBranch = new GitBranch (branchRef.getName(), ObjectId.toString(branchRef.getObjectId()));
            result.add (newBranch);
        }
    } catch (GitAPIException e) {
        throw new IllegalStateException("Could not read branches from Git repository '" + path + "'", e);
    } finally {
        repository.close();
    }

    return result;
}
 
开发者ID:kontext-e,项目名称:jqassistant-plugins,代码行数:19,代码来源:JGitScanner.java

示例5: setListMode

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
/**
 * Sets the listing mode
 *
 * @antdoc.notrequired
 * @param listMode - optional: corresponds to the -r/-a options; by default, only local branches will be listed
 */
public void setListMode(String listMode) {
        if (!GitTaskUtils.isNullOrBlankString(listMode)) {
                try {
                        this.listMode = ListBranchCommand.ListMode.valueOf(listMode);
                }
                catch (IllegalArgumentException e) {
                        ListBranchCommand.ListMode[] listModes = ListBranchCommand.ListMode.values();

                        List<String> listModeValidValues = new ArrayList<String>(listModes.length);

                        for (ListBranchCommand.ListMode aListMode : listModes) {
                                listModeValidValues.add(aListMode.name());
                        }

                        String validModes = listModeValidValues.toString();

                        throw new BuildException(String.format("Valid listMode options are: %s.", validModes));
                }
        }
}
 
开发者ID:rimerosolutions,项目名称:ant-git-tasks,代码行数:27,代码来源:BranchListTask.java

示例6: containsBranch

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
private boolean containsBranch(Git git, String label, ListBranchCommand.ListMode listMode)
		throws GitAPIException {
	ListBranchCommand command = git.branchList();
	if (listMode != null) {
		command.setListMode(listMode);
	}
	List<Ref> branches = command.call();
	for (Ref ref : branches) {
		if (ref.getName().endsWith("/" + label)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-release-tools,代码行数:15,代码来源:GitRepo.java

示例7: checkoutAllBranches

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
private void checkoutAllBranches(Repository repository) throws GitAPIException {
    final Git git = Git.wrap(repository);
    for (final Ref ref : git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call()) {
        final String refName = ref.getName();
        final String branchName = refName.substring(refName.lastIndexOf('/') + 1);
        try {
            git.checkout().setCreateBranch(true).setName(branchName).setStartPoint("origin/" + branchName).call();
        } catch (RefAlreadyExistsException e) {
            LOGGER.warning("Already exists, so ignoring " + e.getMessage());
        }
    }
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:13,代码来源:GitCloner.java

示例8: doListBranches

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
protected List<String> doListBranches(Git git) throws Exception {
    SortedSet<String> names = new TreeSet<String>();
    List<Ref> call = git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call();
    for (Ref ref : call) {
        String name = ref.getName();
        int idx = name.lastIndexOf('/');
        if (idx >= 0) {
            name = name.substring(idx + 1);
        }
        if (name.length() > 0) {
            names.add(name);
        }
    }
    return new ArrayList<String>(names);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:16,代码来源:RepositoryResource.java

示例9: setBranchType

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
/**
 * Determines whether to return local, remote, or all branches for {@code getBranches*()} related methods.
 * @param branchList the branch list command
 * @param branchType the type of branches to include
 */
private static void setBranchType(ListBranchCommand branchList, BranchType branchType) {
    if (branchType.equals(BranchType.LOCAL)) {
        // to get local branches, don't set list mode
        return;
    }

    if (branchType.equals(BranchType.REMOTE)) {
        branchList.setListMode(ListBranchCommand.ListMode.REMOTE);
    } else {
        branchList.setListMode(ListBranchCommand.ListMode.ALL);
    }
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:18,代码来源:GitHelper.java

示例10: containsBranch

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
private boolean containsBranch(Git git, String label, ListMode listMode)
		throws GitAPIException {
	ListBranchCommand command = git.branchList();
	if (listMode != null) {
		command.setListMode(listMode);
	}
	List<Ref> branches = command.call();
	for (Ref ref : branches) {
		if (ref.getName().endsWith("/" + label)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:15,代码来源:JGitEnvironmentRepository.java

示例11: getBranches

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
/**
 * getBranches.
 *
 * @return a {@link java.util.Set} object.
 * @throws hudson.plugins.git.GitException if underlying git operation fails.
 */
public Set<Branch> getBranches() throws GitException {
    try (Repository repo = getRepository()) {
        List<Ref> refs = git(repo).branchList().setListMode(ListBranchCommand.ListMode.ALL).call();
        Set<Branch> branches = new HashSet<>(refs.size());
        for (Ref ref : refs) {
            branches.add(new Branch(ref));
        }
        return branches;
    } catch (GitAPIException e) {
        throw new GitException(e);
    }
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:19,代码来源:JGitAPIImpl.java

示例12: getRemoteBranches

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
/**
 * getRemoteBranches.
 *
 * @return a {@link java.util.Set} object.
 * @throws hudson.plugins.git.GitException if underlying git operation fails.
 */
public Set<Branch> getRemoteBranches() throws GitException {
    try (Repository repo = getRepository()) {
        List<Ref> refs = git(repo).branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call();
        Set<Branch> branches = new HashSet<>(refs.size());
        for (Ref ref : refs) {
            branches.add(new Branch(ref));
        }
        return branches;
    } catch (GitAPIException e) {
        throw new GitException(e);
    }
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:19,代码来源:JGitAPIImpl.java

示例13: isBranch

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
private boolean isBranch(Git git, String label) throws GitAPIException {
	return containsBranch(git, label, ListBranchCommand.ListMode.ALL);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-release-tools,代码行数:4,代码来源:GitRepo.java

示例14: getBranches

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
public static List<Ref> getBranches(Git git, BranchType branchType) throws GitAPIException {
    ListBranchCommand branchList = git.branchList();
    setBranchType(branchList, branchType);
    return branchList.call();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:6,代码来源:GitHelper.java

示例15: branchList

import org.eclipse.jgit.api.ListBranchCommand; //导入依赖的package包/类
@Override
public List<Branch> branchList(BranchListMode listMode) throws GitException {
  ListBranchCommand listBranchCommand = getGit().branchList();
  if (LIST_ALL == listMode || listMode == null) {
    listBranchCommand.setListMode(ListMode.ALL);
  } else if (LIST_REMOTE == listMode) {
    listBranchCommand.setListMode(ListMode.REMOTE);
  }
  List<Ref> refs;
  String currentRef;
  try {
    refs = listBranchCommand.call();
    String headBranch = getRepository().getBranch();
    Optional<Ref> currentTag =
        getGit()
            .tagList()
            .call()
            .stream()
            .filter(tag -> tag.getObjectId().getName().equals(headBranch))
            .findFirst();
    if (currentTag.isPresent()) {
      currentRef = currentTag.get().getName();
    } else {
      currentRef = "refs/heads/" + headBranch;
    }

  } catch (GitAPIException | IOException exception) {
    throw new GitException(exception.getMessage(), exception);
  }
  List<Branch> branches = new ArrayList<>();
  for (Ref ref : refs) {
    String refName = ref.getName();
    boolean isCommitOrTag = HEAD.equals(refName);
    String branchName = isCommitOrTag ? currentRef : refName;
    String branchDisplayName;
    if (isCommitOrTag) {
      branchDisplayName = "(detached from " + Repository.shortenRefName(currentRef) + ")";
    } else {
      branchDisplayName = Repository.shortenRefName(refName);
    }
    Branch branch =
        newDto(Branch.class)
            .withName(branchName)
            .withActive(isCommitOrTag || refName.equals(currentRef))
            .withDisplayName(branchDisplayName)
            .withRemote(refName.startsWith("refs/remotes"));
    branches.add(branch);
  }
  return branches;
}
 
开发者ID:eclipse,项目名称:che,代码行数:51,代码来源:JGitConnection.java


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