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


Java PullResult类代码示例

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


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

示例1: doPull

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
protected void doPull(Exchange exchange, String operation) throws Exception {
    PullResult result = null;
    try {
        if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
            throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
        }
        if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
            git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
        }
        if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
            UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
            result = git.pull().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
        } else {
            result = git.pull().setRemote(endpoint.getRemotePath()).call();
        }
    } catch (Exception e) {
        LOG.error("There was an error in Git " + operation + " operation");
        throw e;
    }
    exchange.getOut().setBody(result);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:GitProducer.java

示例2: testPull

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
@Test
public void testPull() throws Exception {
  // source: db2, target: db
  setupRemote();
  Git git2 = new Git( db2 );

  // put some file in the source repo and sync
  File sourceFile = new File( db2.getWorkTree(), "SomeFile.txt" );
  FileUtils.writeStringToFile( sourceFile, "Hello world" );
  git2.add().addFilepattern( "SomeFile.txt" ).call();
  git2.commit().setMessage( "Initial commit for source" ).call();
  PullResult pullResult = git.pull().call();

  // change the source file
  FileUtils.writeStringToFile( sourceFile, "Another change" );
  git2.add().addFilepattern( "SomeFile.txt" ).call();
  git2.commit().setMessage( "Some change in remote" ).call();
  git2.close();

  assertTrue( uiGit.pull() );
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:22,代码来源:UIGitTest.java

示例3: update

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
private void update(Git git) throws GitAPIException {
    PullResult pullResult = git.pull().setRebase(true).call();
    RebaseResult rebaseResult = pullResult.getRebaseResult();

    if(!pullResult.isSuccessful()) {
        if(rebaseResult.getStatus() == RebaseResult.Status.CONFLICTS) {
            logger.warn("Git `pull` reported conflicts - will reset and try again next pass!");
            git.reset().setMode(ResetCommand.ResetType.HARD).call();
            return;
        }

        logger.warn("Git `pull` was unsuccessful :(");
        return;
    }

    if(rebaseResult.getStatus() == RebaseResult.Status.UP_TO_DATE) {
        logger.debug("Git `pull` reported that repository is already up-to-date");
        return;
    }

    logger.debug("Git repo is now at commit '{}'", rebaseResult.getCurrentCommit());
}
 
开发者ID:AnomalyXII,项目名称:werewolv.es-tools,代码行数:23,代码来源:BotServiceConfiguration.java

示例4: visit

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
private static void visit( File directory ) throws IOException, RefNotFoundException, DetachedHeadException, WrongRepositoryStateException, InvalidRemoteException, InvalidConfigurationException, CanceledException {
    for ( final File child : directory.listFiles() ) {
        if ( child.isDirectory() ) {
            visit( child );
        }
        final String name = child.getName();
        if ( name.equals( ".git" ) ) {

            Thread t = new Thread( new Runnable() {
                public void run() {
                    try {
                        Git git = Git.open( child.getParentFile() );
                        PullResult pullResult = git.pull().call();
                        System.out.println( "pulled on " + child.getParentFile().getName() + ", pullResult = " + pullResult.isSuccessful() + ", " + pullResult.getFetchedFrom() + ", fetch messages: " + pullResult.getFetchResult().getMessages() );
                    }
                    catch ( Exception e ) {
                        e.printStackTrace();
                    }
                }
            } );
            t.start();

        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:PullAll.java

示例5: useLocalGitRepository

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
protected Git useLocalGitRepository(Path repository) throws IOException {
    Git git;
    git = this.gitOperations.openGitRepository(repository);
    if (this.gitOperations.hasAtLeastOneReference(git.getRepository())) {

        final PullResult pullResult = executePull(git);

        if (!pullResult.isSuccessful()) {
            // Merge conflicts
            throw new IllegalArgumentException(
                "There are merge conflicts into an existing git repo. Provider should not deal with merge conflicts. Correct them or delete the repo and execute again the test.");
        }
    } else {
        throw new IllegalArgumentException(String.format("Git repository %s was not cloned correctly.",
            git.getRepository().getDirectory().getAbsolutePath()));
    }
    return git;
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:19,代码来源:GitContractsPublisher.java

示例6: executePull

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
private PullResult executePull(Git git) {
    final PullResult pullResult;
    if (isSet(this.contractsGit.username()) && isSet(this.contractsGit.password())) {

        pullResult = this.gitOperations.pullFromRepository(git,
            getResolvedValue(this.contractsGit.remote()),
            getResolvedValue(this.contractsGit.branch()),
            getResolvedValue(this.contractsGit.username()),
            getResolvedValue(this.contractsGit.password()));
    } else {
        if (isSet(this.contractsGit.passphrase())) {

            pullResult = this.gitOperations.pullFromRepository(git,
                getResolvedValue(this.contractsGit.remote()),
                getResolvedValue(this.contractsGit.branch()),
                getResolvedValue(this.contractsGit.passphrase()),
                getPrivateKey());
        } else {

            pullResult = this.gitOperations.pullFromRepository(git,
                getResolvedValue(this.contractsGit.remote()),
                getResolvedValue(this.contractsGit.branch()));
        }
    }
    return pullResult;
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:27,代码来源:ContractsGitLoader.java

示例7: pullFromRepository

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
/**
 * Pull repository from current branch and remote branch with same name as current
 *
 * @param git
 *     instance.
 * @param remote
 *     to be used.
 * @param remoteBranch
 *     to use.
 * @param passphrase
 *     to access private key.
 * @param privateKey
 *     file location.
 */
public PullResult pullFromRepository(final Git git, final String remote, String remoteBranch, final String passphrase,
    final Path privateKey) {
    SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
        @Override
        protected void configure(OpenSshConfig.Host host, Session session) {
            session.setUserInfo(new PassphraseUserInfo(passphrase));
        }

        @Override
        protected JSch createDefaultJSch(FS fs) throws JSchException {
            if (privateKey != null) {
                JSch defaultJSch = super.createDefaultJSch(fs);
                defaultJSch.addIdentity(privateKey.toFile().getAbsolutePath());
                return defaultJSch;
            } else {
                return super.createDefaultJSch(fs);
            }
        }
    };

    try {
        return git.pull()
            .setRemote(remote)
            .setRemoteBranchName(remoteBranch)
            .setTransportConfigCallback(transport -> {
                SshTransport sshTransport = (SshTransport) transport;
                sshTransport.setSshSessionFactory(sshSessionFactory);
            })
            .call();
    } catch (GitAPIException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:48,代码来源:GitOperations.java

示例8: updateRepository

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
protected IStatus updateRepository(IProgressMonitor monitor) {
	String repoURL = getPreference(ExamplesPreferenceConstants.REMOTE_LOCATION);
	try {
		java.nio.file.Path storageLocation = getStorageLocation();
		PullResult result = Git.open(storageLocation.toFile()).pull()
				.setProgressMonitor(new EclipseGitProgressTransformer(monitor)).call();
		if (!result.isSuccessful()) {
			return new Status(IStatus.ERROR, ExampleActivator.PLUGIN_ID,
					"Unable to update repository " + repoURL + "!");
		}
	} catch (GitAPIException | IOException e) {
		return new Status(IStatus.ERROR, ExampleActivator.PLUGIN_ID,
				"Unable to update repository " + repoURL + "!");
	}
	return Status.OK_STATUS;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:17,代码来源:GitRepositoryExampleService.java

示例9: run

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
@Override
public void run() {
    workspaceProvider.synchronizedOperation(new Callable<Void>() {
        @Override
        public Void call() {
            try {

                final PullResult result = gitProctorCore.getGit()
                        .pull()
                        .setProgressMonitor(PROGRESS_MONITOR)
                        .setRebase(true)
                        .setCredentialsProvider(user)
                        .setTimeout(GitProctorUtils.DEFAULT_GIT_PULL_PUSH_TIMEOUT_SECONDS)
                        .call();
                if (!result.isSuccessful()) {
                    /** if git pull failed, use git reset **/
                    gitProctorCore.undoLocalChanges();
                }
            } catch (final Exception e) {
                LOGGER.error("Error when refreshing git directory " + getDirectoryPath(), e);
            }
            return null;
        }
    });

}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:27,代码来源:GitDirectoryRefresher.java

示例10: refresh

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
public void refresh() {
    workspaceProvider.synchronizedOperation(new Callable<Void>() {
        @Override
        public Void call() {
            try {
                /** git pull is preferable since it's more efficient **/
                LOGGER.debug("Started refresh with git pull");
                final PullResult result = getGit().pull().setProgressMonitor(PROGRESS_MONITOR).setRebase(true).setCredentialsProvider(user).call();
                if (!result.isSuccessful()) {
                    /** if git pull failed, use git reset **/
                    LOGGER.info("refresh failed. Running undo local changes");
                    undoLocalChanges();
                }
                LOGGER.debug("Finished refresh");
            } catch (final Exception e) {
                LOGGER.error("Error when refreshing git directory " + workspaceProvider.getRootDirectory(), e);
            }
            return null;
        }
    });
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:22,代码来源:GitProctorCore.java

示例11: applyBefore

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

示例12: doExecute

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

示例13: main

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = cloneRepository()) {
        System.out.println("Having repository: " + repository.getDirectory() + " with head: " +
                repository.findRef(Constants.HEAD) + "/" + repository.resolve("HEAD") + "/" +
                repository.resolve("refs/heads/master"));

        // TODO: why do we get null here for HEAD?!? See also
// http://stackoverflow.com/questions/17979660/jgit-pull-noheadexception

        try (Git git = new Git(repository)) {
            PullResult call = git.pull().call();

            System.out.println("Pulled from the remote repository: " + call);
        }
    }
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:17,代码来源:PullRemoteRepository.java

示例14: pullRemoteRepo

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
/**
 * pulls the remote git repository to receive changes.
 */
public void pullRemoteRepo() {
    String method = "pullRemoteRepo";
    LOGGER.info("Trying to pull remote repository...");
    localGit = LocalRepoCreater.getLocalGit();
    if (localGit != null) {
        Repository repository = localGit.getRepository();
        try (Git git = new Git(repository)) {

/*
 * Getting The Commit Information of the Remote Repository
 */
            RevWalk walker = new RevWalk(repository);
            RevCommit commit = walker.parseCommit(repository.getRef("HEAD").getObjectId());
            Date commitTime = commit.getAuthorIdent().getWhen();
            String commiterName = commit.getAuthorIdent().getName();
            String commitEmail = commit.getAuthorIdent().getEmailAddress();
            String commitID = repository.getRef("HEAD").getObjectId().getName();

            PullResult pullResult = git.pull().setStrategy(MergeStrategy.THEIRS).call();
            LOGGER.info("Fetch result: " + pullResult.getFetchResult().getMessages());
            LOGGER.info("Merge result: " + pullResult.getMergeResult().toString());
            LOGGER.info("Merge status: " + pullResult.getMergeResult().getMergeStatus());
            repoDiffer.checkForUpdates(git, commiterName, commitEmail, commitTime, commitID);
        } catch (Exception e) {
            LOGGER.error("In method " + method + ": Error while pulling remote git repository.", e);
        }
        localGit.close();
    } else {
        LOGGER.warn("Repository not cloned yet");
    }
}
 
开发者ID:adessoAG,项目名称:jekyll2cms,代码行数:35,代码来源:GitRepoPuller.java

示例15: update

import org.eclipse.jgit.api.PullResult; //导入依赖的package包/类
/**
 * Update a {@link Git} {@link Repository}.
 *
 * @param git the {@link Git} instance to update
 */
protected static void update(Git git) throws RouterException {
    PullResult pullResult;
    try {
        pullResult = git.pull().call();
        // Todo: log some stuff??
    } catch (GitAPIException e) {
        throw new RouterException("Failed to update Git repository: " + e.getMessage(), e);
    }
}
 
开发者ID:AnomalyXII,项目名称:werewolv.es-tools,代码行数:15,代码来源:ArchivedGameService.java


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