Avoid refresh on up-to-date pull operation
[egit/eclipse.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / op / GarbageCollectOperation.java
blobfeb48bcf3af26118931803af1706faac68c7969c
1 /*******************************************************************************
2 * Copyright (C) 2012, 2013 Matthias Sohn <matthias.sohn@sap.com> and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
10 *******************************************************************************/
11 package org.eclipse.egit.core.op;
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.core.runtime.jobs.ISchedulingRule;
18 import org.eclipse.egit.core.Activator;
19 import org.eclipse.egit.core.EclipseGitProgressTransformer;
20 import org.eclipse.egit.core.internal.job.RuleUtil;
21 import org.eclipse.jgit.api.Git;
22 import org.eclipse.jgit.api.errors.GitAPIException;
23 import org.eclipse.jgit.lib.Repository;
25 /**
26 * Operation to garbage collect a git repository
28 public class GarbageCollectOperation implements IEGitOperation {
30 private Repository repository;
32 /**
33 * @param repository the repository to garbage collect
35 public GarbageCollectOperation(Repository repository) {
36 this.repository = repository;
39 /**
40 * Execute garbage collection
42 @Override
43 public void execute(IProgressMonitor monitor) throws CoreException {
44 try (Git git = new Git(repository)) {
45 git.gc().setProgressMonitor(
46 new EclipseGitProgressTransformer(monitor)).call();
47 } catch (GitAPIException e) {
48 throw new CoreException(new Status(IStatus.ERROR,
49 Activator.getPluginId(), e.getMessage(), e));
53 @Override
54 public ISchedulingRule getSchedulingRule() {
55 return RuleUtil.getRule(repository);