List of usage examples for org.eclipse.jgit.lib RepositoryCache clear
public static void clear()
From source file:com.google.gerrit.acceptance.GerritServer.java
License:Apache License
void stop() throws Exception { daemon.getLifecycleManager().stop(); if (daemonService != null) { System.out.println("Gerrit Server Shutdown"); daemonService.shutdownNow();/* w w w .j a v a 2 s . com*/ daemonService.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } RepositoryCache.clear(); }
From source file:com.google.gerrit.pgm.init.api.AllProjectsConfig.java
License:Apache License
private void save(PersonIdent ident, String msg) throws IOException { File path = getPath();// w w w. ja v a 2 s .co m if (path == null) { throw new IOException("All-Projects does not exist."); } try (Repository repo = new FileRepository(path)) { inserter = repo.newObjectInserter(); reader = repo.newObjectReader(); try (RevWalk rw = new RevWalk(reader)) { RevTree srcTree = revision != null ? rw.parseTree(revision) : null; newTree = readTree(srcTree); saveConfig(ProjectConfig.PROJECT_CONFIG, cfg); saveGroupList(); ObjectId res = newTree.writeTree(inserter); if (res.equals(srcTree)) { // If there are no changes to the content, don't create the commit. return; } CommitBuilder commit = new CommitBuilder(); commit.setAuthor(ident); commit.setCommitter(ident); commit.setMessage(msg); commit.setTreeId(res); if (revision != null) { commit.addParentId(revision); } ObjectId newRevision = inserter.insert(commit); updateRef(repo, ident, newRevision, "commit: " + msg); revision = newRevision; } finally { if (inserter != null) { inserter.close(); inserter = null; } if (reader != null) { reader.close(); reader = null; } } } // we need to invalidate the JGit cache if the group list is invalidated in // an unattended init step RepositoryCache.clear(); }
From source file:eu.hohenegger.gitmine.jgit.TestBasic.java
License:Open Source License
@After public void tearDown() throws Exception { RepositoryCache.clear(); git.getRepository().close(); }
From source file:io.fabric8.git.internal.FabricGitServiceImpl.java
License:Apache License
@Deactivate void deactivate() { deactivateComponent(); RepositoryCache.clear(); }
From source file:org.eclipse.releng.tests.LocalDiskRepositoryTest.java
License:Eclipse Distribution License
protected void tearDown() throws Exception { RepositoryCache.clear(); for (Iterator it = toClose.iterator(); it.hasNext();) { Repository r = (Repository) it.next(); r.close();//from www.j a v a 2s . co m } toClose.clear(); }
From source file:org.webcat.core.git.GitUtilities.java
License:Open Source License
/** * Gets the Git repository that is located in the file store area for the * specified object, creating it if necessary. * * @param object the EO object whose file store contains the Git repository * @return the repository/*w w w . j a v a 2 s .co m*/ */ /*package*/ static Repository repositoryForObject(EOBase object) { File fsDir = Application.wcApplication().repositoryPathForObject(object); File wcDir = Application.wcApplication().workingCopyPathForObject(object); Repository repository = null; if (fsDir != null) { File masterRef = new File(fsDir, "refs/heads/master"); if (!masterRef.exists()) { // If the directory exists but we don't have a master ref, then // the repository is probably corrupted. Blow away the // directory, clear the repository cache, and then the code // below will re-create it for us. log.warn("Found the directory for the repository at " + fsDir.getAbsolutePath() + ", but it appears to be " + "corrupt (no master ref). Re-creating it..."); RepositoryCache.clear(); FileUtilities.deleteDirectory(fsDir); fsDir.mkdirs(); } try { try { repository = RepositoryCache.open(FileKey.lenient(fsDir, FS.DETECTED), true); if (repository == null) { log.error("RepositoryCache.open returned null for " + "object " + object); } } catch (RepositoryNotFoundException e) { log.info("Creating repository at " + fsDir + " for the first time"); repository = setUpNewRepository(object, fsDir); } catch (Exception e) { log.error("An exception occurred while trying to get the " + "repository for object " + object, e); } } catch (IOException e) { log.error("An exception occurred while trying to get the " + "repository for object " + object, e); } } RepositoryInfo repoInfo = new RepositoryInfo(); repoInfo.repositoryDir = fsDir; repoInfo.workingCopyDir = wcDir; repositoryInfos.put(repository, repoInfo); return repository; }