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


Java PullCommand类代码示例

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


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

示例1: doPull

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
protected void doPull(File gitFolder, CredentialsProvider cp, String branch, PersonIdent personIdent, UserDetails userDetails) {
    try {
        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        Repository repository = builder.setGitDir(gitFolder)
                .readEnvironment() // scan environment GIT_* variables
                .findGitDir() // scan up the file system tree
                .build();

        Git git = new Git(repository);

        File projectFolder = repository.getDirectory();

        StoredConfig config = repository.getConfig();
        String url = config.getString("remote", userDetails.getRemote(), "url");
        if (Strings.isNullOrBlank(url)) {
            LOG.warn("No remote repository url for " + branch + " defined for the git repository at " + projectFolder.getCanonicalPath() + " so cannot pull");
            //return;
        }
        String mergeUrl = config.getString("branch", branch, "merge");
        if (Strings.isNullOrBlank(mergeUrl)) {
            LOG.warn("No merge spec for branch." + branch + ".merge in the git repository at " + projectFolder.getCanonicalPath() + " so not doing a pull");
            //return;
        }

        LOG.debug("Performing a pull in git repository " + projectFolder.getCanonicalPath() + " on remote URL: " + url);
        PullCommand pull = git.pull();
        GitHelpers.configureCommand(pull, userDetails);
        pull.setRebase(true).call();
    } catch (Throwable e) {
        LOG.error("Failed to pull from the remote git repo with credentials " + cp + " due: " + e.getMessage() + ". This exception is ignored.", e);
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:33,代码来源:GitBuildConfigProcessor.java

示例2: gitPull

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
/**
 * Execute git pull command on the given repository.
 * It populates an ArrayList with all the updated files.
 * @param localPath The path where the project is.
 * @return Returns true if you should update plugins, false otherwise.
 */
private boolean gitPull(File localPath) {
    try {
        Repository localRepo = new FileRepository(localPath.getAbsolutePath() + "/.git");
        git = new Git(localRepo);
        
        populateDiff();
        
        if(!pluginsToUpdate.isEmpty()){
            PullCommand pullCmd = git.pull();
            pullCmd.call();
            return true;
        }
        else{
            return false;
        }
        
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    return true;
}
 
开发者ID:Neembuu-Uploader,项目名称:neembuu-uploader,代码行数:29,代码来源:UpdaterGenerator.java

示例3: gitPull

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
/**
 * Execute git pull command on the given repository.
 * It populates an ArrayList with all the updated files.
 * @param localPath The path where the project is.
 * @return Returns true if you should update plugins, false otherwise.
 */
private boolean gitPull(File localPath) {
    try {
        Repository localRepo = new FileRepository(localPath.getAbsolutePath() + "/.git");
        git = new Git(localRepo);
        
        
        
        if(populateDiff()){
            PullCommand pullCmd = git.pull();
            pullCmd.call();
            return true;
        }
        else{
            return false;
        }
        
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    return true;
}
 
开发者ID:Neembuu-Uploader,项目名称:neembuu-uploader,代码行数:29,代码来源:UpdaterGenerator.java

示例4: applyBefore

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
public static Boolean applyBefore(final Git git) {
    Boolean result = Boolean.FALSE;
    try {
        PullCommand pc = git.pull().setRemote(REMOTE).setRebase(Boolean.TRUE);
        PullResult pullRes = pc.call();
        RebaseResult rr = pullRes.getRebaseResult();

        if (rr.getStatus().equals(RebaseResult.Status.UP_TO_DATE) || rr.getStatus().equals(RebaseResult.Status.FAST_FORWARD)) {
            result = Boolean.TRUE;
        }
        if (rr.getStatus().equals(RebaseResult.Status.UNCOMMITTED_CHANGES)) {
            PullResult pr = git.pull().call();
            if (pr.isSuccessful()) {
                result = Boolean.TRUE;
            } else {
                result = Boolean.FALSE;
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage());
    }
    return result;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:24,代码来源:JGitUtils.java

示例5: 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);
        }
}
 
开发者ID:rimerosolutions,项目名称:ant-git-tasks,代码行数:27,代码来源:PullTask.java

示例6: 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());
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:15,代码来源:JGitBasedClient.java

示例7: doPull

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
protected void doPull(Git git, GitContext context) throws GitAPIException {
    StopWatch watch = new StopWatch();

    LOG.info("Performing a pull in git repository " + this.gitFolder + " on remote URL: " + this.remoteRepository);
    CredentialsProvider cp = userDetails.createCredentialsProvider();
    PullCommand command = git.pull();
    configureCommand(command, userDetails);
    command.setCredentialsProvider(cp).setRebase(true).call();
    LOG.info("Took " + watch.taken() + " to complete pull in git repository " + this.gitFolder + " on remote URL: " + this.remoteRepository);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:11,代码来源:RepositoryResource.java

示例8: 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();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:24,代码来源:GitHelper.java

示例9: 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();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:24,代码来源:GitHelper.java

示例10: execute

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
@Override
public void execute() {
    if (this.provider != null) {
        ((PullCommand) this.command).setCredentialsProvider(this.provider);
    }
    new GitAsyncTask(callingActivity, true, false, this).execute(this.command);
}
 
开发者ID:zeapo,项目名称:Android-Password-Store,代码行数:8,代码来源:PullOperation.java

示例11: initWithCredentials

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
public void initWithCredentials(File repoDir, String url, Optional<CredentialsProvider> credentialsProvider)
		throws Exception {
	this.credentialsProvider = credentialsProvider;
	try {
		repository = Git.open(repoDir);
		PullCommand pullCmd = repository.pull();
		credentialsProvider.ifPresent(c -> pullCmd.setCredentialsProvider(c));
		pullCmd.call();
	} catch (IOException ex) {
		// failed to open, so we clone it anew
		CloneCommand cloneCmd = Git.cloneRepository();
		credentialsProvider.ifPresent(c -> cloneCmd.setCredentialsProvider(c));
		repository = cloneCmd.setDirectory(repoDir).setURI(url).call();
	}
}
 
开发者ID:warmuuh,项目名称:pactbroker-maven-plugin,代码行数:16,代码来源:GitApi.java

示例12: doInBackground

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
@Override
protected Long doInBackground(GitCommand<?>... params) {
	GitCommand<?> command = params[0];
	
	Utils.announceSyncStart(context, projectName);

	if(command instanceof CloneCommand) {
		((CloneCommand)command).setProgressMonitor(monitor);
		status = "Cloning";
	} else if(command instanceof PullCommand) {
		((PullCommand)command).setProgressMonitor(monitor);
		status = "Pulling";
	} else {
		throw new IllegalArgumentException(
				"Coudln't attach progressMonitor to git command");
	}
	
	publishProgress(-1);
	
	try {
		command.call();
	} catch (Exception e) {
		status = e.getLocalizedMessage();
		publishProgress(100);
	}
	return 0L;
}
 
开发者ID:hdweiss,项目名称:codemap,代码行数:28,代码来源:JGitWrapper.java

示例13: 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;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:55,代码来源:SourceControlManager.java

示例14: pullCommand

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
private PullCommand pullCommand(String branch, Git git) {
    if (Strings.isNullOrEmpty(branch)) {
        return buildCommand(git.pull());
    }
    return buildCommand(git.pull().setRemoteBranchName(branch)).setTimeout(GIT_TRANS_TIMEOUT);
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:7,代码来源:JGitBasedClient.java

示例15: execute

import org.eclipse.jgit.api.PullCommand; //导入依赖的package包/类
@Override
public void execute(Wandora wandora, Context context) {

    try {
        Git git = getGit();
        if(git != null) {
            if(isNotEmpty(getGitRemoteUrl())) {
                PullCommand pull = git.pull();
                String user = getUsername();
                if(user == null) {
                    if(pullUI == null) {
                        pullUI = new PullUI();
                    }
                    pullUI.setUsername(getUsername());
                    pullUI.setPassword(getPassword());
                    pullUI.setRemoteUrl(getGitRemoteUrl());

                    pullUI.openInDialog();

                    if(pullUI.wasAccepted()) {
                        setUsername(pullUI.getUsername());
                        setPassword(pullUI.getPassword());
                        // setGitRemoteUrl(pullUI.getRemoteUrl());    
                        
                        // pull.setRemote(pullUI.getRemoteUrl());
                        if(isNotEmpty(getUsername())) {
                            CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider( getUsername(), getPassword() );
                            pull.setCredentialsProvider(credentialsProvider);
                        }
                    }
                    else {
                        return;
                    }
                }

                setDefaultLogger();
                setLogTitle("Git pull");

                log("Pulling changes from remote repository...");
                PullResult result = pull.call();

                FetchResult fetchResult = result.getFetchResult();
                MergeResult mergeResult = result.getMergeResult();
                MergeStatus mergeStatus = mergeResult.getMergeStatus();

                String fetchResultMessages = fetchResult.getMessages();
                if(isNotEmpty(fetchResultMessages)) {
                    log(fetchResult.getMessages());
                }
                log(mergeStatus.toString());

                if(mergeStatus.equals(MergeStatus.MERGED)) {
                    int a = WandoraOptionPane.showConfirmDialog(wandora, "Reload Wandora project after pull?", "Reload Wandora project after pull?", WandoraOptionPane.YES_NO_OPTION);
                    if(a == WandoraOptionPane.YES_OPTION) {
                        reloadWandoraProject();
                    }
                }
                log("Ready.");
            }
            else {
                log("Repository has no remote origin and can't be pulled. " 
                    + "Initialize repository by cloning remote repository to set the remote origin.");
            }
        }
        else {
            logAboutMissingGitRepository();
        }
    }
    catch(GitAPIException gae) {
        log(gae.toString());
    }
    catch(NoWorkTreeException nwte) {
        log(nwte.toString());
    }
    catch(Exception e) {
        log(e);
    }
    setState(WAIT);
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:80,代码来源:Pull.java


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