org.eclipse.jgit.api.Git.fetch()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(391)

本文整理了Java中org.eclipse.jgit.api.Git.fetch()方法的一些代码示例,展示了Git.fetch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.fetch()方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:fetch

Git.fetch介绍

[英]Return a command object to execute a Fetch command
[中]返回命令对象以执行Fetch命令

代码示例

代码示例来源:origin: spring-cloud/spring-cloud-config

protected FetchResult fetch(Git git, String label) {
  FetchCommand fetch = git.fetch();
  fetch.setRemote("origin");
  fetch.setTagOpt(TagOpt.FETCH_TAGS);
  fetch.setRemoveDeletedRefs(deleteUntrackedBranches);
  if (this.refreshRate > 0) {
    this.setLastRefresh(System.currentTimeMillis());
  }
  configureCommand(fetch);
  try {
    FetchResult result = fetch.call();
    if (result.getTrackingRefUpdates() != null
        && result.getTrackingRefUpdates().size() > 0) {
      logger.info("Fetched for remote " + label + " and found "
          + result.getTrackingRefUpdates().size() + " updates");
    }
    return result;
  }
  catch (Exception ex) {
    String message = "Could not fetch remote for " + label + " remote: " + git
        .getRepository().getConfig().getString("remote", "origin", "url");
    warn(message, ex);
    return null;
  }
}

代码示例来源:origin: centic9/jgit-cookbook

public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
      System.out.println("Starting fetch");
      try (Git git = new Git(repository)) {
        FetchResult result = git.fetch().setCheckFetchedObjects(true).call();
        System.out.println("Messages: " + result.getMessages());
      }
    }
  }
}

代码示例来源:origin: centic9/jgit-cookbook

public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
      System.out.println("Starting fetch");
      try (Git git = new Git(repository)) {
        FetchResult result = git.fetch().setCheckFetchedObjects(true).call();
        System.out.println("Messages: " + result.getMessages());
      }
    }
  }
}

代码示例来源:origin: apache/incubator-gobblin

this.git.fetch()
  .setRemote(REMOTE_NAME)
  .setCredentialsProvider(getCredentialsProvider())

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

private void fetch() {
 FetchCommand fetchCommand = Git.wrap(git).fetch();
 try {
  fetchCommand.setThin(true).call();
 } catch (Exception e) {
  log.error("Failed to perform fetch", e);
 }
}

代码示例来源:origin: jphp-group/jphp

@Signature
public Memory fetch(ArrayMemory settings) throws GitAPIException {
  FetchCommand command = getWrappedObject().fetch();

代码示例来源:origin: centic9/jgit-cookbook

FetchResult result = git.fetch().setCheckFetchedObjects(true).call();
System.out.println("Messages: " + result.getMessages());

代码示例来源:origin: FlowCI/flow-platform

/**
 * fetch tags from remote
 * @param path
 * @param remoteName
 * @return
 * @throws GitException
 */
public static Path fetchTags(Path path, String remoteName) throws GitException {
  try (Git git = Git.open(path.toFile())) {
    git.fetch()
      .setRemote(remoteName)
      .setRefSpecs(new RefSpec("refs/tags/*:refs/tags/*"))
      .setTagOpt(TagOpt.FETCH_TAGS)
      .call();
  } catch (Throwable throwable) {
    throw new GitException("fetch tags error", throwable);
  }
  return path;
}

代码示例来源:origin: centic9/jgit-cookbook

FetchResult result = git.fetch().setCheckFetchedObjects(true).call();
System.out.println("Messages: " + result.getMessages());

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

fetchCallback.fetchingSubmodule(generator.getPath());
FetchCommand fetchCommand = Git.wrap(repository).fetch();
if (monitor != null) {
  fetchCommand.setProgressMonitor(monitor);

代码示例来源:origin: stackoverflow.com

Repository repository = FileRepositoryBuilder.create(gitDir);
Git git = Git.wrap(repository);
FetchResult result = git.fetch().call();
for (TrackingRefUpdate refUpdate : result.getTrackingRefUpdates()) {
  // ...
}

代码示例来源:origin: stackoverflow.com

Git git = Git.init().setDirectory(new File("fetchtest/test/")).call();

git.fetch().setRemote(new File("../main.git"))
      .setRefSpecs(new RefSpec("refs/heads/foo:refs/heads/foo"))
      .call();

代码示例来源:origin: org.apereo.cas/cas-mgmt-support-version-control

private boolean checkMaster() throws GitAPIException {
  val fr = git.fetch().setDryRun(true).call();
  git.close();
  return !fr.getTrackingRefUpdates().isEmpty();
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

@Override
public FetchCommand fetch() {
  return configure(super.fetch()).setProgressMonitor(progressMonitor("fetch"));
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

@Override
public FetchCommand fetch() {
  return configure(super.fetch()).setProgressMonitor(progressMonitor("fetch"));
}

代码示例来源:origin: io.ultreia.java4all.jgitflow/jgitflow-core

protected void doFetchIfNeeded(JGitFlowExtension fetchingExtension) throws GitAPIException, JGitFlowGitAPIException, JGitFlowExtensionException
{
  if (fetch)
  {
    runExtensionCommands(fetchingExtension.beforeFetch());
    git.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).call();
    runExtensionCommands(fetchingExtension.afterFetch());
  }
}

代码示例来源:origin: external.atlassian.jgitflow/jgit-flow-core

protected void doFetchIfNeeded(JGitFlowExtension fetchingExtension) throws GitAPIException, JGitFlowGitAPIException, JGitFlowExtensionException
{
  if (fetch)
  {
    runExtensionCommands(fetchingExtension.beforeFetch());
    git.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).call();
    runExtensionCommands(fetchingExtension.afterFetch());
  }
}

代码示例来源:origin: danielflower/app-runner

private void gitUpdateFromOrigin() throws GitAPIException {
  git.fetch().setRemote("origin").call();
  git.reset().setMode(ResetCommand.ResetType.HARD).setRef("origin/master").call();
  this.contributors = getContributorsFromRepo();
}

代码示例来源:origin: org.walkmod/junit4git

public Ref fetchNotesRef(Git git) throws IOException, GitAPIException {
 Ref ref = git.getRepository().findRef(GIT_NOTES_REF);
 if (areNotesInRemote(git)) {
  git.fetch().setRemote("origin")
      .setDryRun(false)
      .setRefSpecs(new RefSpec(GIT_NOTES_REF + ":" + GIT_NOTES_REF))
      .call();
 }
 return ref;
}

代码示例来源:origin: robinst/git-merge-repos

private void fetch() throws GitAPIException {
  for (SubtreeConfig config : subtreeConfigs) {
    RefSpec branchesSpec = new RefSpec(
        "refs/heads/*:refs/heads/original/"
            + config.getRemoteName() + "/*");
    RefSpec tagsSpec = new RefSpec("refs/tags/*:refs/tags/original/"
        + config.getRemoteName() + "/*");
    Git git = new Git(repository);
    git.fetch().setRemote(config.getFetchUri().toPrivateString())
        .setRefSpecs(branchesSpec, tagsSpec).call();
  }
}

相关文章