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

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

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

Git.close介绍

[英]Free resources associated with this instance.

If the repository was opened by a static factory method in this class, then this method calls Repository#close() on the underlying repository instance. (Whether this actually releases underlying resources, such as file handles, may vary; see Repository for more details.)

If the repository was created by a caller and passed into #Git(Repository) or a static factory method in this class, then this method does not call close on the underlying repository.

In all cases, after calling this method you should not use this Git instance anymore.
[中]与此实例关联的可用资源。
如果存储库是由此类中的静态工厂方法打开的,那么该方法将调用基础存储库实例上的repository#close()。(这是否实际释放了底层资源,如文件句柄,可能会有所不同;有关更多详细信息,请参阅存储库。)
如果存储库是由调用方创建的,并传递到此类中的#Git(存储库)或静态工厂方法中,则此方法不会对基础存储库调用close。
在所有情况下,调用此方法后,您都不应该再使用此Git实例。

代码示例

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

/**
 * Clones the remote repository and then opens a connection to it.
 *
 * @throws GitAPIException
 * @throws IOException
 */
private void initClonedRepository() throws GitAPIException, IOException {
  if (!getUri().startsWith(FILE_URI_PREFIX)) {
    deleteBaseDirIfExists();
    Git git = cloneToBasedir();
    if (git != null) {
      git.close();
    }
    git = openGitRepository();
    if (git != null) {
      git.close();
    }
  }
}

代码示例来源:origin: gocd/gocd

@After
public void tearDown() throws Exception {
  configRepo.git().close();
  configRepo.getGitRepo().close();
}

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

try {
  if (git != null) {
    git.close();

代码示例来源:origin: uber/chaperone

} finally {
 output.close();
 git.close();
 if (result != null)
  result.getRepository().close();

代码示例来源:origin: org.hudsonci.plugins/git

/**
 * Close the underlying Git object.
 * After close, no executable call, e.g., <code>commit</code> is allowed.
 */
public void close() {
  if (jGitDelegate != null) {
    jGitDelegate.close();
    jGitDelegate = null;
  }
}

代码示例来源:origin: ch.sbb.releasetrain/git

@Override
public void reset() {
  try {
    if (git == null) {
      return;
    }
    git.close();
    FileUtils.deleteDirectory(this.gitDir);
  } catch (IOException e) {
    log.error("not able to delete folder: " + this.gitDir, e);
  }
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public void close() {
  if (mainRepository != null) {
    mainRepository.close();
  }
  RepositoryCache.clear();
}

代码示例来源:origin: io.vertx/vertx-config-git

@Override
 public void close(Handler<Void> completionHandler) {
  vertx.runOnContext(v -> {
   if (git != null) {
    git.close();
   }
   completionHandler.handle(null);
  });
 }
}

代码示例来源:origin: io.fabric8.patch/patch-management

@Override
public void close() {
  if (mainRepository != null) {
    mainRepository.close();
  }
  RepositoryCache.clear();
}

代码示例来源:origin: io.macgyver/macgyver-plugin-git

public void close() {
  if (repo != null) {
    repo.close();
  }
  if (git != null) {
    git.close();
  }
}

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

/**
 * Closes the git repository.
 */
@Override
public void close() {
  if (!isUndefined()) {
    git.close();
  }
}

代码示例来源:origin: line/centraldogma

@Override
public void close() {
  try {
    super.close();
  } finally {
    try {
      getRepository().close();
    } finally {
      lock.unlock();
    }
  }
}

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

@Override
public void close() {
  try {
    super.close();
  } finally {
    try {
      getRepository().close();
    } finally {
      lock.unlock();
    }
  }
}

代码示例来源:origin: cfg4j/cfg4j

@Override
public void close() throws IOException {
 if (clonedRepo != null) {
  LOG.debug("Closing local repository: " + clonedRepoPath);
  clonedRepo.close();
  new FileUtils().deleteDir(clonedRepoPath);
 }
}

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

@Override
public void close() {
  try {
    super.close();
  } finally {
    try {
      getRepository().close();
    } finally {
      lock.unlock();
    }
  }
}

代码示例来源:origin: org.apache.camel/camel-git

@Override
protected void doStop() throws Exception {
  super.doStop();
  repo.close();
  git.close();
}

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

Git git = Git.cloneRepository().setURI( REMOTE_URL ).setDirectory( new File( "local/path/to/repo" ) ).call();
File gitDir = git.getRepository().getDirectory();
git.close();
// ...
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir( gitDir ).setMustExist( true ).build();

代码示例来源:origin: org.springframework.cloud/spring-cloud-contract-stub-runner

private String currentBranch(File projectDir) {
  Git git = this.gitFactory.open(projectDir);
  try {
    return git.getRepository().getBranch();
  }
  catch (IOException e) {
    throw new IllegalStateException(e);
  }
  finally {
    git.close();
  }
}

代码示例来源:origin: cfg4j/cfg4j

/**
 * Remove this repository. Silently fails if repo already removed.
 */
@Override
public void remove() {
 try {
  repo.close();
  super.remove();
 } catch (IOException e) {
  // NOP
 }
}

代码示例来源: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();
}

相关文章