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