本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}