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


Java PushCommand.setRefSpecs方法代码示例

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


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

示例1: pushOne

import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
public static PushResult pushOne(
    TestRepository<?> testRepo,
    String source,
    String target,
    boolean pushTags,
    boolean force,
    List<String> pushOptions)
    throws GitAPIException {
  PushCommand pushCmd = testRepo.git().push();
  pushCmd.setForce(force);
  pushCmd.setPushOptions(pushOptions);
  pushCmd.setRefSpecs(new RefSpec((source != null ? source : "") + ":" + target));
  if (pushTags) {
    pushCmd.setPushTags();
  }
  Iterable<PushResult> r = pushCmd.call();
  return Iterables.getOnlyElement(r);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:GitUtil.java

示例2: pushCommentsAndReviews

import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
/**
 * Pushes the local comments and reviews back to the origin.
 */
private void pushCommentsAndReviews() throws Exception {
  try (Git git = new Git(repo)) {
    RefSpec spec = new RefSpec(DEVTOOLS_PUSH_REFSPEC);
    PushCommand pushCommand = git.push();
    pushCommand.setRefSpecs(spec);
    pushCommand.call();
  }
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:12,代码来源:AppraiseGitReviewClient.java

示例3: pushTag

import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
public static PushResult pushTag(TestRepository<?> testRepo, String tag, boolean force)
    throws GitAPIException {
  PushCommand pushCmd = testRepo.git().push();
  pushCmd.setForce(force);
  pushCmd.setRefSpecs(new RefSpec("refs/tags/" + tag + ":refs/tags/" + tag));
  Iterable<PushResult> r = pushCmd.call();
  return Iterables.getOnlyElement(r);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:GitUtil.java

示例4: push

import org.eclipse.jgit.api.PushCommand; //导入方法依赖的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.PushCommand.setRefSpecs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。