@Override public void close() throws IOException { if (!isClosed) { try { if (repository != null) { repository.close(); } closeGits(); if (isTempDirectory) { deleteTempDirectory(); } } finally { isClosed = true; } } }
@After public void tearDown() throws Exception { configRepo.git().close(); configRepo.getGitRepo().close(); }
/** * {@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(); }
@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(); } } };
@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(); } }
out_w = new PipedOutputStream(out_r); } catch (IOException err) { remote.close(); throw new TransportException(uri, JGitText.get().cannotConnectPipes, err);
out_w = new PipedOutputStream(out_r); } catch (IOException err) { remote.close(); throw new TransportException(uri, JGitText.get().cannotConnectPipes, err);
} 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;
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(); } }
public void close() { if (repo != null) { repo.close(); } if (git != null) { git.close(); } }
@Override public void close() throws IOException { // Is this ThreadSafe ? git.getRepository().close(); }
public synchronized void reconnect() throws IOException { Repository newLocalRepo = new FileRepository(new File(localDir + "/.git")); git = new Git(newLocalRepo); localRepo.close(); localRepo = newLocalRepo; }
@Override public void close() { try { super.close(); } finally { try { getRepository().close(); } finally { lock.unlock(); } } }
@Override public void close() { try { super.close(); } finally { try { getRepository().close(); } finally { lock.unlock(); } } }
@Deactivate void deactivate() { deactivateComponent(); RepositoryCache.clear(); git.status().getRepository().close(); }
@Override public void closeRepository(Git git, boolean deleteWorkingCopy) { git.getRepository().close(); if (deleteWorkingCopy) { FileUtils.deleteQuietly(git.getRepository().getDirectory()); FileUtils.deleteQuietly(git.getRepository().getWorkTree()); } }
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; }