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


Java FetchResult类代码示例

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


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

示例1: fetch

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
private List<TrackingRefUpdate> fetch(Repository repository) throws Exception {
       logger.info("Fetching changes of repository {}", repository.getDirectory().toString());
       try (Git git = new Git(repository)) {
   		FetchResult result = git.fetch().call();
   		
   		Collection<TrackingRefUpdate> updates = result.getTrackingRefUpdates();
   		List<TrackingRefUpdate> remoteRefsChanges = new ArrayList<TrackingRefUpdate>();
   		for (TrackingRefUpdate update : updates) {
   			String refName = update.getLocalName();
   			if (refName.startsWith(REMOTE_REFS_PREFIX)) {
   				ObjectId newObjectId = update.getNewObjectId();
   				logger.info("{} is now at {}", refName, newObjectId.getName());
   				remoteRefsChanges.add(update);
   			}
   		}
   		if (updates.isEmpty()) {
   			logger.info("Nothing changed");
   		}
   		return remoteRefsChanges;
       }
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:22,代码来源:GitServiceImpl.java

示例2: fetch

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
@Override
public String fetch(String localBranchName, String remoteBranchName) {
    
    RefSpec spec = new RefSpec().setSourceDestination(localBranchName, remoteBranchName);
    FetchCommand command = _git.fetch();
    command.setRefSpecs(spec);
    FetchResult result = null;
    try {
        result = command.call();
    } catch (Throwable e) {
        throw new RuntimeException(String.format(
                "Failed to fetch from [%s] to [%s]",
                remoteBranchName,
                localBranchName), e);
    }
    
    return result.getMessages();
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:19,代码来源:JGitOperator.java

示例3: shouldSetTransportConfigCallbackOnCloneAndFetch

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
@Test
public void shouldSetTransportConfigCallbackOnCloneAndFetch() throws Exception {
	Git mockGit = mock(Git.class);
	FetchCommand fetchCommand = mock(FetchCommand.class);
	when(mockGit.fetch()).thenReturn(fetchCommand);
	when(fetchCommand.call()).thenReturn(mock(FetchResult.class));

	CloneCommand mockCloneCommand = mock(CloneCommand.class);
	when(mockCloneCommand.setURI(anyString())).thenReturn(mockCloneCommand);
	when(mockCloneCommand.setDirectory(any(File.class))).thenReturn(mockCloneCommand);

	TransportConfigCallback configCallback = mock(TransportConfigCallback.class);
	JGitEnvironmentRepository envRepository = new JGitEnvironmentRepository(this.environment);
	envRepository.setGitFactory(new MockGitFactory(mockGit, mockCloneCommand));
	envRepository.setUri("http://somegitserver/somegitrepo");
	envRepository.setTransportConfigCallback(configCallback);
	envRepository.setCloneOnStart(true);

	envRepository.afterPropertiesSet();
	verify(mockCloneCommand, times(1)).setTransportConfigCallback(configCallback);

	envRepository.fetch(mockGit, "master");
	verify(fetchCommand, times(1)).setTransportConfigCallback(configCallback);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:25,代码来源:JGitEnvironmentRepositoryTests.java

示例4: fetchRepository

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
/**
 * Fetch updates from the remote repository. If refSpecs is unspecifed, remote heads, tags, and notes are retrieved.
 * 
 * @param credentialsProvider
 * @param repository
 * @param refSpecs
 * @return FetchResult
 * @throws Exception
 */
public static FetchResult fetchRepository(CredentialsProvider credentialsProvider, Repository repository, RefSpec... refSpecs) throws Exception {
	try (Git git = new Git(repository)) {
		FetchCommand fetch = git.fetch();
		List<RefSpec> specs = new ArrayList<RefSpec>();
		if (refSpecs == null || refSpecs.length == 0) {
			specs.add(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
			specs.add(new RefSpec("+refs/tags/*:refs/tags/*"));
			specs.add(new RefSpec("+refs/notes/*:refs/notes/*"));
		} else {
			specs.addAll(Arrays.asList(refSpecs));
		}
		if (credentialsProvider != null) {
			fetch.setCredentialsProvider(credentialsProvider);
		}
		fetch.setRefSpecs(specs);
		FetchResult fetchRes = fetch.call();
		return fetchRes;
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:29,代码来源:JGitUtils.java

示例5: iCloneRepository

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
@Given("^I clone repository \"([^\"]*)\"$")
public void iCloneRepository(String name) throws Throwable {
    workFolder = Files.createTempDir();
    RepositoryModel repositoryModel = repositoriesApi.getRepository(name)
        .getRepositoryModel();

    repositoryName = name;
    git = Git.init().setBare(false).setDirectory(workFolder).call();

    RemoteAddCommand addCommand = git.remoteAdd();
    addCommand.setName(REMOTE_ORIGIN);
    addCommand.setUri(new URIish(repositoryModel.getUrl() + ".git"));
    addCommand.call();

    FetchResult fetchResult = git.fetch().setRemote(REMOTE_ORIGIN).call();

    if (!fetchResult.getAdvertisedRefs().isEmpty()) {
        git.pull().setRemote(REMOTE_ORIGIN).setRemoteBranchName(MASTER_BRANCH_NAME).call();
    }

}
 
开发者ID:devhub-tud,项目名称:git-server,代码行数:22,代码来源:CloneStepDefinitions.java

示例6: fetchRepository

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
/**
 * Fetch updates from the remote repository. If refSpecs is unspecifed,
 * remote heads, tags, and notes are retrieved.
 * 
 * @param credentialsProvider
 * @param repository
 * @param refSpecs
 * @return FetchResult
 * @throws Exception
 */
public static FetchResult fetchRepository(CredentialsProvider credentialsProvider,
		Repository repository, RefSpec... refSpecs) throws Exception {
	Git git = new Git(repository);
	FetchCommand fetch = git.fetch();
	List<RefSpec> specs = new ArrayList<RefSpec>();
	if (refSpecs == null || refSpecs.length == 0) {
		specs.add(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
		specs.add(new RefSpec("+refs/tags/*:refs/tags/*"));
		specs.add(new RefSpec("+refs/notes/*:refs/notes/*"));
	} else {
		specs.addAll(Arrays.asList(refSpecs));
	}
	if (credentialsProvider != null) {
		fetch.setCredentialsProvider(credentialsProvider);
	}
	fetch.setRefSpecs(specs);
	FetchResult fetchRes = fetch.call();
	return fetchRes;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:30,代码来源:JGitUtils.java

示例7: doExecute

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

示例8: fetch

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
private List<TrackingRefUpdate> fetch(Repository repository) throws Exception {
	try (Git git = new Git(repository)) {
		FetchResult result = git.fetch().call();
		
		Collection<TrackingRefUpdate> updates = result.getTrackingRefUpdates();
		List<TrackingRefUpdate> remoteRefsChanges = new ArrayList<TrackingRefUpdate>();
		for (TrackingRefUpdate update : updates) {
			String refName = update.getLocalName();
			if (refName.startsWith(REMOTE_REFS_PREFIX)) {
				remoteRefsChanges.add(update);
			}
		}
		return remoteRefsChanges;
	}
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:16,代码来源:GitHelper.java

示例9: fetch

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
/**
 * Fetches all content from the given remote. Note: this command will also prune deleted references
 * @param git the git repository
 * @param remoteName the name of the remote or the uri of the remote
 * @return result of the fetch
 * @throws GitAPIException
 */
public static FetchResult fetch(Git git, String remoteName) throws GitAPIException {
    return git.fetch()
            .setRemote(remoteName)
            .setCheckFetchedObjects(true)
            .setRemoveDeletedRefs(true)
            .call();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:15,代码来源:GitHelper.java

示例10: cloneProject

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
public static TestRepository<InMemoryRepository> cloneProject(Project.NameKey project, String uri)
    throws Exception {
  DfsRepositoryDescription desc = new DfsRepositoryDescription("clone of " + project.get());

  FS fs = FS.detect();

  // Avoid leaking user state into our tests.
  fs.setUserHome(null);

  InMemoryRepository dest =
      new InMemoryRepository.Builder()
          .setRepositoryDescription(desc)
          // SshTransport depends on a real FS to read ~/.ssh/config, but
          // InMemoryRepository by default uses a null FS.
          // TODO(dborowitz): Remove when we no longer depend on SSH.
          .setFS(fs)
          .build();
  Config cfg = dest.getConfig();
  cfg.setString("remote", "origin", "url", uri);
  cfg.setString("remote", "origin", "fetch", "+refs/heads/*:refs/remotes/origin/*");
  TestRepository<InMemoryRepository> testRepo = newTestRepository(dest);
  FetchResult result = testRepo.git().fetch().setRemote("origin").call();
  String originMaster = "refs/remotes/origin/master";
  if (result.getTrackingRefUpdate(originMaster) != null) {
    testRepo.reset(originMaster);
  }
  return testRepo;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:29,代码来源:GitUtil.java

示例11: onCommandGitFetch

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
private boolean onCommandGitFetch(Caller caller, String workspaceName, Git git, String remote) {
    GitExecutor<FetchResult> executor = new GitExecutor<FetchResult>(caller, workspaceName, new GitFetchHandler());
    FetchCommand command = git.fetch()
            .setRemote(remote != null ? remote : "origin")
            .setProgressMonitor(executor)
            .setTagOpt(TagOpt.FETCH_TAGS)
            .setCredentialsProvider(executor);
    executor.setCommand(command);
    plugin.getServer().getScheduler().runTaskAsynchronously(plugin,executor);
    return true;
}
 
开发者ID:DPOH-VAR,项目名称:VarScript,代码行数:12,代码来源:WorkspaceCommandExecutor.java

示例12: commitToMergeFor

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
private AnyObjectId commitToMergeFor(FetchResult fetchRes, String remoteBranchName, boolean remote) {
    // we check the updates to see which of the updated branches
    // corresponds
    // to the remote branch name
    AnyObjectId commitToMerge;
    if (remote) {
        Ref r = null;
        if (fetchRes != null) {
            r = fetchRes.getAdvertisedRef(remoteBranchName);
            if (r == null)
                r = fetchRes.getAdvertisedRef(R_HEADS + remoteBranchName);
        }
        if (r == null)
            throw new JGitInternalException(MessageFormat.format(JGitText
                    .get().couldNotGetAdvertisedRef, remoteBranchName));
        else
            commitToMerge = r.getObjectId();
    } else {
        try {
            commitToMerge = repo.resolve(remoteBranchName);
            if (commitToMerge == null)
                throw exceptionMessage(R.string.ref_not_resolved, remoteBranchName);
        } catch (IOException e) {
            throw new JGitInternalException(
                    JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,
                    e);
        }
    }
    return commitToMerge;
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:31,代码来源:Pull.java

示例13: fetch

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
public FetchResult fetch(String remote, Collection<RefSpec> toFetch) {
    Log.d(TAG, "About to run fetch : " + remote);

    for (Map.Entry<String,Ref> entry : git.getRepository().getAllRefs().entrySet()) {
        Log.d(TAG, entry.getKey()+" = "+entry.getValue());
    }
    FetchResult fetchResult = null;
    try {
        fetchResult = git.fetch()
                .setRemote(remote)
                .setRefSpecs(toFetch == null ? Collections.<RefSpec>emptyList() : newArrayList(toFetch))
                .setProgressMonitor(messagingProgressMonitor)
                .setTransportConfigCallback(transportConfigCallback)
                .setCredentialsProvider(credentialsProvider)
                .call();
    } catch (GitAPIException e) {
        throw exceptionWithFriendlyMessageFor(e);
    }
    Log.d(TAG, "Fetch complete with : " + fetchResult+" messages="+fetchResult.getMessages());
    for (Ref ref : fetchResult.getAdvertisedRefs()) {
        Log.d(TAG, "AdvertisedRef : " + ref.getName()+" objectId="+ref.getObjectId());
    }
    for (TrackingRefUpdate update : fetchResult.getTrackingRefUpdates()) {
        Log.d(TAG, "TrackingRefUpdate : " + update.getLocalName() + " old=" + update.getOldObjectId() + " new=" + update.getNewObjectId());
    }
    repoUpdateBroadcaster.broadcastUpdate();
    return fetchResult;
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:29,代码来源:GitFetchService.java

示例14: synchronize

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
protected void synchronize() {
	//
	// Grab our working repository
	//
	Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
	try {
		final Git git = Git.open(repoPath.toFile());
		
		PullResult result = git.pull().call();
		FetchResult fetch = result.getFetchResult();
		MergeResult merge = result.getMergeResult();
		RebaseResult rebase = result.getRebaseResult();
		if (result.isSuccessful()) {
			//
			// TODO add more notification
			//
			this.textAreaResults.setValue("Successful!");
		} else {
			//
			// TODO
			//
			this.textAreaResults.setValue("Failed.");
		}
	} catch (IOException | GitAPIException e) {
		e.printStackTrace();
	}
	this.buttonSynchronize.setCaption("Ok");
}
 
开发者ID:att,项目名称:XACML,代码行数:29,代码来源:GitSynchronizeWindow.java

示例15: doApply

import org.eclipse.jgit.transport.FetchResult; //导入依赖的package包/类
@Override
public Context doApply(Context context) throws Throwable {
    final Repository repository = new FileRepositoryBuilder()
        .setGitDir(context.getProjectPath())
            // scan environment GIT_* variables
        .readEnvironment()
        .findGitDir()
        .setMustExist(true)
        .build();
    context.setRepository(repository);

    logger.info("Fetching '{}' repository at path: '{}'", context.getName(), context.getProjectPath());

    Git git = new Git(repository);

    FetchResult fetchResult = git.fetch()
        .setProgressMonitor(new LoggingProgressMonitor(logger))
        .call();

    Collection<Ref> refs = FluentIterable
        .from(fetchResult.getTrackingRefUpdates())
        .filter(Predicates.not(new Predicate<TrackingRefUpdate>() {
            @Override
            public boolean apply(TrackingRefUpdate input) {
                return NO_CHANGE.equals(input.getResult());
            }
        }))
        .transform(new TrackingRefUpdateToRef(repository))
        .toList();

    context.setRefs(refs);
    logger.info("Found {} refs to process.", refs.size());
    return context;
}
 
开发者ID:obazoud,项目名称:elasticsearch-river-git,代码行数:35,代码来源:FetchRepositoryFunction.java


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