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


Java ListMode类代码示例

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


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

示例1: main

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
        Repository repo = Commands.getRepo(Consts.META_REPO_PATH);

        Git git = new Git(repo);

        // Create a new branch
        git.branchCreate().setName("newBranch").call();
// Checkout the new branch
        git.checkout().setName("newBranch").call();
        // List the existing branches
        List<Ref> listRefsBranches = git.branchList().setListMode(ListMode.ALL).call();
        listRefsBranches.forEach((refBranch) -> {
            System.out.println("Branch : " + refBranch.getName());
        });
// Go back on "master" branch and remove the created one
        git.checkout().setName("master");
        git.branchDelete().setBranchNames("newBranch");
    }
 
开发者ID:alexmy21,项目名称:gmds,代码行数:19,代码来源:Branches.java

示例2: retreiveBranches

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
@Override
public List<String> retreiveBranches() {
	List <String> receivedListAsString = new ArrayList<>();
	List <Ref> receivedList;
	try {
		receivedList = _git.branchList().setListMode(ListMode.ALL).call();
		for (Ref ref : receivedList) {
			receivedListAsString.add(ref.getName());
		}
	} catch (GitAPIException e) {
		VerigreenLogger.get().log(
                   getClass().getName(),
                   RuntimeUtils.getCurrentMethodName(), "Failed to receive branches list");
		return null;
	}
	return receivedListAsString;
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:18,代码来源:JGitOperator.java

示例3: getBranches

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
/**
 * Get a list of branches based on mode
 * @param mode
 * @return
 */
private List<String> getBranches( ListMode mode ) {
  try {
    return git.branchList().setListMode( mode ).call().stream()
      .filter( ref -> !ref.getName().endsWith( Constants.HEAD ) )
      .map( ref -> Repository.shortenRefName( ref.getName() ) )
      .collect( Collectors.toList() );
  } catch ( Exception e ) {
    e.printStackTrace();
  }
  return null;
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:17,代码来源:UIGit.java

示例4: getBranch

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
public static Ref getBranch(String repositoryPath,ObjectId id) throws IOException, GitAPIException{
    Git git = new Git(new FileRepository(repositoryPath+"/.git"));
    ListBranchCommand list = git.branchList().setListMode(ListMode.ALL);
    List<Ref> call = list.call();
    Ref ref = null;
    for(Ref r:call){
    	if(r.getObjectId().equals(id)){
    		ref = r;
    	}
    }
    return ref;
}
 
开发者ID:piiiiq,项目名称:Black,代码行数:13,代码来源:test.java

示例5: cloneAll

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
public void cloneAll(String host) throws InvalidRemoteException, TransportException, GitAPIException{
	Git git = Git.cloneRepository().setURI(host).setNoCheckout(true).setCloneAllBranches(true).call();
	List<Ref> branches = git.branchList().setListMode( ListMode.REMOTE ).call();
	for(Ref r:branches){
		System.out.println(r.getName());
	}
}
 
开发者ID:piiiiq,项目名称:Black,代码行数:8,代码来源:test.java

示例6: doShowBranches

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
protected void doShowBranches(Exchange exchange, String operation) throws Exception {
    List<Ref> result = null;
    try {
        result = git.branchList().setListMode(ListMode.ALL).call();
    } catch (Exception e) {
        LOG.error("There was an error in Git " + operation + " operation");
        throw e;
    }
    exchange.getOut().setBody(result);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:GitProducer.java

示例7: getRevision

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
private Revision getRevision(RevCommit commit, String filePath)
    throws GitAPIException, IOException {
  List<String> commitParentsList =
      Stream.of(commit.getParents()).map(RevCommit::getName).collect(Collectors.toList());

  return newDto(Revision.class)
      .withId(commit.getId().getName())
      .withMessage(commit.getFullMessage())
      .withCommitTime((long) commit.getCommitTime() * 1000)
      .withCommitter(getCommitCommitter(commit))
      .withAuthor(getCommitAuthor(commit))
      .withBranches(getBranchesOfCommit(commit, ListMode.ALL))
      .withCommitParent(commitParentsList)
      .withDiffCommitFile(getCommitDiffFiles(commit, filePath));
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:JGitConnection.java

示例8: getBranchesOfCommit

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
private List<Branch> getBranchesOfCommit(RevCommit commit, ListMode mode) throws GitAPIException {
  List<Ref> branches =
      getGit().branchList().setListMode(mode).setContains(commit.getName()).call();
  return branches
      .stream()
      .map(branch -> newDto(Branch.class).withName(branch.getName()))
      .collect(toList());
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:JGitConnection.java

示例9: getBranches

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
@Override
public void getBranches(final List<String> names, final List<String> commits) {
	try {
		for (final Ref ref : git.branchList().setListMode(ListMode.REMOTE).call()) {
			names.add(ref.getName());
			commits.add(ref.getObjectId().getName());
		}
	} catch (final GitAPIException e) {
		if (debug)
			System.err.println("Git Error reading branches: " + e.getMessage());
	}
}
 
开发者ID:boalang,项目名称:compiler,代码行数:13,代码来源:GitConnector.java

示例10: containsBranch

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的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.ListMode; //导入依赖的package包/类
@Override
public Collection<BranchModel> getBranches() {
	try {
		return git.branchList()
			.setListMode(ListMode.ALL)
			.call().stream()
			.map(this::transformToBranchModel)
			.collect(Collectors.toList());
	}
	catch (GitAPIException e) {
		throw new GitException(e.getMessage(), e);
	}
}
 
开发者ID:devhub-tud,项目名称:git-server,代码行数:14,代码来源:JGitRepositoryFacade.java

示例12: getBranches

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
@Override
public Stream<VersionInfo> getBranches() throws IOException {
    try {
        return refToVersionInfo(repo.branchList().setListMode(ListMode.ALL).call().stream());
    } catch (GitAPIException ex) {
        throw new IOException(ex);
    }
}
 
开发者ID:fuzzyBSc,项目名称:systemdesign,代码行数:9,代码来源:GitVersionControl.java

示例13: getDefaultBaseline

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
@Override
public Optional<VersionInfo> getDefaultBaseline() {
    try {
        return refToVersionInfo(
                repo.branchList()
                .setListMode(ListMode.ALL)
                .setContains("HEAD")
                .call()
                .stream()).findAny();
    } catch (GitAPIException ex) {
        return Optional.empty();
    }
}
 
开发者ID:fuzzyBSc,项目名称:systemdesign,代码行数:14,代码来源:GitVersionControl.java

示例14: branchList

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的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

示例15: push

import org.eclipse.jgit.api.ListBranchCommand.ListMode; //导入依赖的package包/类
@Override
public boolean push(String sourceBranch, String destinationBranch) {
       
       PushCommand command = _git.push();
       boolean ret = true;
       RefSpec refSpec = new RefSpec().setSourceDestination(sourceBranch, destinationBranch);
       command.setRefSpecs(refSpec);
       try {
       	List<Ref> remoteBranches = _git.branchList().setListMode(ListMode.REMOTE).call();
           Iterable<PushResult> results = command.call();
           for (PushResult pushResult : results) {
           	Collection<RemoteRefUpdate> resultsCollection = pushResult.getRemoteUpdates();
           	Map<PushResult,RemoteRefUpdate> resultsMap = new HashMap<>();
           	for(RemoteRefUpdate remoteRefUpdate : resultsCollection)
           	{
           		resultsMap.put(pushResult, remoteRefUpdate);
           	}
           	
               RemoteRefUpdate remoteUpdate = pushResult.getRemoteUpdate(destinationBranch);
               if (remoteUpdate != null) {
                   org.eclipse.jgit.transport.RemoteRefUpdate.Status status =
                           remoteUpdate.getStatus();
                   ret =
                           status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.OK)
                                   || status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.UP_TO_DATE);
               }
               
               if(remoteUpdate == null && !remoteBranches.toString().contains(destinationBranch))
               {	
            
               	
               	for(RemoteRefUpdate resultValue : resultsMap.values())
               	{
               		if(resultValue.toString().contains("REJECTED_OTHER_REASON"))
               		{
               			ret = false;
               		}
               	}
               }	
           }
       } catch (Throwable e) {
           throw new RuntimeException(String.format(
                   "Failed to push [%s] into [%s]",
                   sourceBranch,
                   destinationBranch), e);
       }
       
       return ret;
   }
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:50,代码来源:JGitOperator.java


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