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

x33g5p2x  于2022-01-28 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(221)

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

Repository.close介绍

[英]Decrement the use count, and maybe close resources.
[中]减少使用次数,可能会关闭资源。

代码示例

代码示例来源:origin: oracle/helidon

@Override
public void close() throws IOException {
  if (!isClosed) {
    try {
      if (repository != null) {
        repository.close();
      }
      closeGits();
      if (isTempDirectory) {
        deleteTempDirectory();
      }
    } finally {
      isClosed = true;
    }
  }
}

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

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

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

/**
 * {@inheritDoc}
 * <p>
 * Free resources associated with this instance.
 * <p>
 * If the repository was opened by a static factory method in this class,
 * then this method calls {@link Repository#close()} on the underlying
 * repository instance. (Whether this actually releases underlying
 * resources, such as file handles, may vary; see {@link Repository} for
 * more details.)
 * <p>
 * If the repository was created by a caller and passed into
 * {@link #Git(Repository)} or a static factory method in this class, then
 * this method does not call close on the underlying repository.
 * <p>
 * In all cases, after calling this method you should not use this
 * {@link Git} instance anymore.
 *
 * @since 3.2
 */
@Override
public void close() {
  if (closeRepo)
    repo.close();
}

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

@Override
  public void run() {
    try {
      final UploadPack rp = uploadPackFactory.create(req, remote);
      rp.upload(out_r, in_w, null);
    } catch (ServiceNotEnabledException e) {
      // Ignored. Client cannot use this repository.
    } catch (ServiceNotAuthorizedException e) {
      // Ignored. Client cannot use this repository.
    } catch (IOException err) {
      // Client side of the pipes should report the problem.
      err.printStackTrace();
    } catch (RuntimeException err) {
      // Client side will notice we went away, and report.
      err.printStackTrace();
    } finally {
      try {
        out_r.close();
      } catch (IOException e2) {
        // Ignore close failure, we probably crashed above.
      }
      try {
        in_w.close();
      } catch (IOException e2) {
        // Ignore close failure, we probably crashed above.
      }
      remote.close();
    }
  }
};

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

remote.close();

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

@Override
public void finalCleanUp() {
 if (revWalk != null) {
  revWalk.dispose();
 }
 // http://www.programcreek.com/java-api-examples/index.php?api=org.eclipse.jgit.storage.file.WindowCacheConfig
 // Example 3
 if (git != null) {
  git.close();
  // git.close() is not enough with jGit on Windows
  // remove the references from packFile by initializing cache used in the repository
  // fixing lock issues on Windows when repository has pack files
  WindowCacheConfig config = new WindowCacheConfig();
  config.install();
 }
}

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

out_w = new PipedOutputStream(out_r);
} catch (IOException err) {
  remote.close();
  throw new TransportException(uri, JGitText.get().cannotConnectPipes, err);

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

out_w = new PipedOutputStream(out_r);
} catch (IOException err) {
  remote.close();
  throw new TransportException(uri, JGitText.get().cannotConnectPipes, err);

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

} catch (IOException ioe) {
  if (repository != null) {
    repository.close();
} catch (URISyntaxException e) {
  if (repository != null) {
    repository.close();
} catch (GitAPIException | RuntimeException e) {
  if (repository != null) {
    repository.close();
    checkout(repository, fetchResult);
  } catch (IOException ioe) {
    repository.close();
    throw new JGitInternalException(ioe.getMessage(), ioe);
  } catch (GitAPIException | RuntimeException e) {
    repository.close();
    throw e;

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

git.close();
if (result != null)
 result.getRepository().close();
backupRepo.close();

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

db.close();
throw new RepositoryNotFoundException(name, e);
db.close();
throw new RepositoryNotFoundException(name, e);
db.close();
throw e;

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

private void addSubmodule(String name, String url, String path,
    String revision, List<CopyFile> copyfiles, List<LinkFile> linkfiles,
    Git git) throws GitAPIException, IOException {
  assert (!repo.isBare());
  assert (git != null);
  if (!linkfiles.isEmpty()) {
    throw new UnsupportedOperationException(
        JGitText.get().nonBareLinkFilesNotSupported);
  }
  SubmoduleAddCommand add = git.submoduleAdd().setName(name).setPath(path)
      .setURI(url);
  if (monitor != null)
    add.setProgressMonitor(monitor);
  Repository subRepo = add.call();
  if (revision != null) {
    try (Git sub = new Git(subRepo)) {
      sub.checkout().setName(findRef(revision, subRepo)).call();
    }
    subRepo.close();
    git.add().addFilepattern(path).call();
  }
  for (CopyFile copyfile : copyfiles) {
    copyfile.copy();
    git.add().addFilepattern(copyfile.dest).call();
  }
}

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

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

代码示例来源:origin: indeedeng/proctor

@Override
public void close() throws IOException {
  // Is this ThreadSafe ?
  git.getRepository().close();
}

代码示例来源:origin: com.centurylink.mdw/mdw-common

public synchronized void reconnect() throws IOException {
  Repository newLocalRepo = new FileRepository(new File(localDir + "/.git"));
  git = new Git(newLocalRepo);
  localRepo.close();
  localRepo = newLocalRepo;
}

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

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

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

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

代码示例来源:origin: io.fabric8/fabric-git

@Deactivate
void deactivate() {
  deactivateComponent();
  RepositoryCache.clear();
  git.status().getRepository().close();
}

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

@Override
public void closeRepository(Git git, boolean deleteWorkingCopy) {
  git.getRepository().close();
  if (deleteWorkingCopy) {
    FileUtils.deleteQuietly(git.getRepository().getDirectory());
    FileUtils.deleteQuietly(git.getRepository().getWorkTree());
  }
}

代码示例来源:origin: gradle.plugin.br.com.sabium/gradle-bump

String getLatestReleaseTag(final String releaseTagPattern) throws IOException, GitAPIException {
  final Pattern tagPattern = Pattern.compile(releaseTagPattern);
  final FileRepositoryBuilder builder = new FileRepositoryBuilder();
  final Repository repository = builder.setWorkTree(new File(gitDir)).findGitDir().build();
  final RevWalk walk = new RevWalk(repository);
  walk.markStart(walk.parseCommit(repository.resolve("HEAD")));
  final String tag = new Git(repository).describe().call();
  walk.reset();
  final Matcher releaseTagMatcher = tagPattern.matcher(tag);
  repository.close();
  return releaseTagMatcher.matches() ? tag : null;
}

相关文章

Repository类方法