Java Code Examples for org.eclipse.jgit.api.ListBranchCommand#ListMode

The following examples show how to use org.eclipse.jgit.api.ListBranchCommand#ListMode . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BranchListTask.java    From ant-git-tasks with Apache License 2.0 6 votes vote down vote up
/**
 * 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));
                }
        }
}
 
Example 2
Source File: GitRepo.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: GitRepo.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: JGitAPIImpl.java    From git-client-plugin with MIT License 5 votes vote down vote up
public Set<Branch> getBranchesInternal(ListBranchCommand.ListMode mode) throws GitException {
    try (Repository repo = getRepository()) {
        List<Ref> refs = git(repo).branchList().setListMode(mode).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);
    }
}