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


Java ListBranchCommand.call方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: call

import org.eclipse.jgit.api.ListBranchCommand; //导入方法依赖的package包/类
public List<String[]> call(final GitInfoStep gitInfoStep, Git git,
    CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
    throws InvalidRemoteException, TransportException, GitAPIException,
    IllegalArgumentException, IOException {

  final List<String[]> branchs = new ArrayList<String[]>();

  final ListBranchCommand ac = git
      .branchList()
      .setListMode(
          ("remote".equalsIgnoreCase(gitInfoStep
              .environmentSubstitute(this.listMode)) ? ListMode.REMOTE
              : ListMode.ALL));
  final List<Ref> refBranchs = ac.call();

  for (Ref refBranch : refBranchs) {
    final String[] branch = new String[] {null, null, null, null,
        null, null, null, null, null, null};

    branch[0] = refBranch.getObjectId().getName(); // Id
    branch[1] = refBranch.getName(); // Name

    final RevObject object = new RevWalk(git.getRepository())
        .parseAny(refBranch.getObjectId());
    if (object instanceof RevCommit) {
      branch[2] = ((RevCommit) object).getFullMessage(); // Commit
      // message
      branch[3] = ((RevCommit) object).getShortMessage(); // Commit
      // message
      branch[4] = dt.format(((RevCommit) object).getAuthorIdent()
          .getWhen()); // Author Date
      branch[5] = ((RevCommit) object).getAuthorIdent().getName(); // Author
      // name
      branch[6] = ((RevCommit) object).getAuthorIdent()
          .getEmailAddress(); // Author email
      branch[7] = dt.format(((RevCommit) object).getCommitterIdent()
          .getWhen()); // Committer Date
      branch[8] = ((RevCommit) object).getCommitterIdent().getName(); // Committer
      // name
      branch[9] = ((RevCommit) object).getCommitterIdent()
          .getEmailAddress(); // Committer email
    }

    branchs.add(branch);
  }

  return branchs;
}
 
开发者ID:ivylabs,项目名称:ivy-pdi-git-steps,代码行数:49,代码来源:ListBranchsGitCommand.java

示例6: refreshBranchList

import org.eclipse.jgit.api.ListBranchCommand; //导入方法依赖的package包/类
private BranchInfo refreshBranchList(String selected) throws IOException, GitAPIException {
    branches.clear();

    ListBranchCommand bl = git.branchList();
    List<Ref> refs = bl.call();

    String current = repository.getFullBranch();
    BranchInfo selectedInfo = null;

    prompt = "Manage branches from <untracked>:";
    for (Ref ref : refs) {
        BranchInfo info = new BranchInfo();
        info.ref = ref;

        info.name = branchName(ref);
        if (ref.getName().equals(current)) {
            info.current = true;
            info.uncommitted = hasUncommitted();
            currentInfo = info;
        }
        if (selected == null) {
            if (ref.getName().equals(current)) {
                selectedInfo = info;
            }
        } else {
            if (info.name.equals(selected)) {
                selectedInfo = info;
            }
        }

        info.diffbase = gt.getDiffbase(info.name);
        info.remote = gt.getRemote(info.name);

        Ref currentRef = repository.getRef(gt.refName(info.name));
        Ref diffWithRef = repository.getRef(gt.refName(info.diffbase));

        ObjectId currentHead = currentRef.getObjectId();
        ObjectId diffWithHead = diffWithRef.getObjectId();

        List<RevCommit> localCommits = ImmutableList.copyOf(git.log().addRange(diffWithHead, currentHead).call());
        List<RevCommit> remoteCommits = ImmutableList.copyOf(git.log().addRange(currentHead, diffWithHead).call());

        info.commits = localCommits.size();
        info.missing = remoteCommits.size();

        longestBranchName = Math.max(longestBranchName, CharUtil.printableWidth(info.name));
        longestRemoteName = Math.max(longestRemoteName, CharUtil.printableWidth(info.diffbase));

        branches.add(info);
    }

    Comparator<BranchInfo> comparator = (l, r) -> {
        if (l.name.equals(gt.getDefaultBranch())) {
            return -1;
        }
        if (r.name.equals(gt.getDefaultBranch())) {
            return 1;
        }
        return l.name.compareTo(r.name);
    };
    branches.sort(comparator);
    return selectedInfo == null ? currentInfo : selectedInfo;
}
 
开发者ID:morimekta,项目名称:gittool,代码行数:64,代码来源:GtBranch.java

示例7: getBranchesWithCommit

import org.eclipse.jgit.api.ListBranchCommand; //导入方法依赖的package包/类
/**
 * Gets the list of branches that contain the given commit
 * @param git the git repository
 * @param commit a commit ID or ref name
 * @return the list of branches with the given commit
 * @throws GitAPIException
 */
public static List<Ref> getBranchesWithCommit(Git git, BranchType branchType, String commit) throws GitAPIException {
    ListBranchCommand branchList = git.branchList();
    setBranchType(branchList, branchType);
    branchList.setContains(commit);
    return branchList.call();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:14,代码来源:GitHelper.java


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