本文整理汇总了Java中org.eclipse.jgit.api.PullCommand.setProgressMonitor方法的典型用法代码示例。如果您正苦于以下问题:Java PullCommand.setProgressMonitor方法的具体用法?Java PullCommand.setProgressMonitor怎么用?Java PullCommand.setProgressMonitor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.api.PullCommand
的用法示例。
在下文中一共展示了PullCommand.setProgressMonitor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import org.eclipse.jgit.api.PullCommand; //导入方法依赖的package包/类
@Override
public void doExecute() {
try {
PullCommand pullCommand = git.pull().setRebase(rebase);
if (getProgressMonitor() != null) {
pullCommand.setProgressMonitor(getProgressMonitor());
}
setupCredentials(pullCommand);
PullResult pullResult = pullCommand.call();
if (!pullResult.isSuccessful()) {
FetchResult fetchResult = pullResult.getFetchResult();
GitTaskUtils.validateTrackingRefUpdates(MESSAGE_PULLED_FAILED, fetchResult.getTrackingRefUpdates());
MergeStatus mergeStatus = pullResult.getMergeResult().getMergeStatus();
if (!mergeStatus.isSuccessful()) {
throw new BuildException(String.format(MESSAGE_PULLED_FAILED_WITH_STATUS, mergeStatus.name()));
}
}
}
catch (Exception e) {
throw new GitBuildException(String.format(MESSAGE_PULLED_FAILED_WITH_URI, getUri()), e);
}
}
示例2: pull
import org.eclipse.jgit.api.PullCommand; //导入方法依赖的package包/类
@Override
public void pull(String branch, ProgressMonitor monitor) throws GitException {
try (Git git = gitOpen()) {
PullCommand pullCommand = pullCommand(branch, git);
if (monitor != null) {
pullCommand.setProgressMonitor(monitor);
} else {
pullCommand.setProgressMonitor(new DebugProgressMonitor());
}
pullCommand.call();
} catch (Throwable e) {
throw new GitException("Fail to pull with specific files: " + ExceptionUtil.findRootCause(e).getMessage());
}
}
示例3: pullWithMerge
import org.eclipse.jgit.api.PullCommand; //导入方法依赖的package包/类
/**
* Pulls from the given repository and merges changes from the given remote branch into
* the local checked-out branch using the given strategy. Progress is reported via the {@code monitor}.
* @param git the git repository
* @param strategy the merge strategy:
* @param remoteName the name of the repository
* @param branchName the name of the remote branch
* @param monitor reports the progress of the pull
* @return result of the pull
* @throws GitAPIException
*/
public static PullResult pullWithMerge(Git git, MergeStrategy strategy, String remoteName, String branchName,
ProgressMonitor monitor) throws GitAPIException {
PullCommand pull = git.pull();
if (monitor != null) { pull.setProgressMonitor(monitor); }
return pull
.setStrategy(strategy)
.setRemote(remoteName) // value -> current branch config -> DEFAULT_REMOTE_NAME = "origin"
.setRemoteBranchName(branchName) // value -> current branch config -> current branch name
.call();
}
示例4: pullWithRebase
import org.eclipse.jgit.api.PullCommand; //导入方法依赖的package包/类
/**
* Pulls from the given repository and rebases the currently checked-out branch onto the given remote branch
* and includes a report on the progress of the pull.
* @param git the git repository
* @param remoteName the name of the remote repository
* @param branchName the name of the branch on which to rebase the current branch
* @param monitor reports the progress of the pull
* @return result of the pull
* @throws GitAPIException
*/
public static PullResult pullWithRebase(Git git, String remoteName, String branchName,
ProgressMonitor monitor) throws GitAPIException {
PullCommand pull = git.pull();
if (monitor != null) { pull.setProgressMonitor(monitor); }
return pull
.setRebase(true) // when true, ignores merge strategy
.setRemote(remoteName) // value -> current branch config -> DEFAULT_REMOTE_NAME = "origin"
.setRemoteBranchName(branchName) // value -> current branch config -> current branch name
.setProgressMonitor(monitor)
.call();
}
示例5: pullGitUpdate
import org.eclipse.jgit.api.PullCommand; //导入方法依赖的package包/类
public void pullGitUpdate ( String scmUserid, String encodedPass, File sourceLocation,
Writer outputWriter )
throws Exception {
String message = "\n\n *** Updating existing branch on git repository: "
+ sourceLocation.getAbsolutePath()
+ "\n Optional: use service clean to delete build location to force a new clone on new branch to be created.";
logger.info( "{}", message );
outputWriter.append( "\n" + message );
outputWriter.flush();
FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder();
repositoryBuilder.findGitDir( sourceLocation );
File gitLocation = repositoryBuilder.getGitDir();
ObjectId oldHead = null;
try (Repository repository = repositoryBuilder.setWorkTree( gitLocation ).build()) {
oldHead = repository.resolve( "HEAD^{tree}" );
}
try (Git git = Git.open( gitLocation )) {
// FetchCommand fetchCommand = git.fetch();
PullCommand pullCommand = git.pull();
if ( scmUserid.length() > 0 ) {
pullCommand.setCredentialsProvider(
new UsernamePasswordCredentialsProvider(
scmUserid,
encryptor.decrypt( encodedPass ) ) );
}
pullCommand.setProgressMonitor( gitMonitor( outputWriter ) );
PullResult result = pullCommand.call();
logger.info( "merge results: {}", result.getMergeResult() );
outputWriter.append( "\n" + result.getMergeResult() + "\n\n Updated files:" );
outputWriter.flush();
printGitModifications( gitLocation, outputWriter, repositoryBuilder, oldHead, git );
// ResetCommand command = git.reset() ;
// command.setP
// command.setMode( ResetType.HARD ).call() ;
}
// catch (Exception e) {
// logger.error( "Failed to complete pull and diff of repository: {}",
// csapApp.getCsapFilteredStackTrace( e ) );
// isSuccessful = false;
// }
logger.info( "git sync complete" );
outputWriter.append( "\n\n ================= git sync complete =============\n\n" );
outputWriter.flush();
return;
}