List of usage examples for org.eclipse.jgit.api GarbageCollectCommand setProgressMonitor
public GarbageCollectCommand setProgressMonitor(ProgressMonitor monitor)
From source file:com.gitblit.transport.ssh.git.GarbageCollectionCommand.java
License:Apache License
@Override protected void runImpl() throws IOException, Failure { try {//from w w w. j a v a2s . co m GarbageCollectCommand gc = Git.wrap(repo).gc(); logGcInfo("before:", gc.getStatistics()); gc.setProgressMonitor(NullProgressMonitor.INSTANCE); Properties statistics = gc.call(); logGcInfo("after: ", statistics); } catch (Exception e) { throw new Failure(1, "fatal: Cannot run gc: ", e); } }
From source file:com.google.gerrit.server.git.GarbageCollection.java
License:Apache License
public GarbageCollectionResult run(List<Project.NameKey> projectNames, boolean aggressive, PrintWriter writer) { GarbageCollectionResult result = new GarbageCollectionResult(); Set<Project.NameKey> projectsToGc = gcQueue.addAll(projectNames); for (Project.NameKey projectName : Sets.difference(Sets.newHashSet(projectNames), projectsToGc)) { result.addError(new GarbageCollectionResult.Error( GarbageCollectionResult.Error.Type.GC_ALREADY_SCHEDULED, projectName)); }//from w w w.j a va 2 s . co m for (Project.NameKey p : projectsToGc) { try (Repository repo = repoManager.openRepository(p)) { logGcConfiguration(p, repo, aggressive); print(writer, "collecting garbage for \"" + p + "\":\n"); GarbageCollectCommand gc = Git.wrap(repo).gc(); gc.setAggressive(aggressive); logGcInfo(p, "before:", gc.getStatistics()); gc.setProgressMonitor( writer != null ? new TextProgressMonitor(writer) : NullProgressMonitor.INSTANCE); Properties statistics = gc.call(); logGcInfo(p, "after: ", statistics); print(writer, "done.\n\n"); fire(p, statistics); } catch (RepositoryNotFoundException e) { logGcError(writer, p, e); result.addError(new GarbageCollectionResult.Error( GarbageCollectionResult.Error.Type.REPOSITORY_NOT_FOUND, p)); } catch (Exception e) { logGcError(writer, p, e); result.addError(new GarbageCollectionResult.Error(GarbageCollectionResult.Error.Type.GC_FAILED, p)); } finally { gcQueue.gcFinished(p); } } return result; }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.GitGcProcess.java
License:Apache License
public static void main(String... args) throws Exception { GitServerUtil.configureExternalProcessLogger(false); try {//w w w . ja v a 2 s.com String gitDir = args[0]; System.out.println("run gc in " + gitDir); Repository r = new RepositoryBuilder().setBare().setGitDir(new File(gitDir)).build(); Git git = new Git(r); GarbageCollectCommand gc = git.gc(); gc.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out))); gc.call(); } catch (Throwable t) { if (isImportant(t)) { t.printStackTrace(System.err); } else { System.err.println(t.getMessage()); } System.exit(1); } }