Example usage for org.eclipse.jgit.api FetchCommand setDryRun

List of usage examples for org.eclipse.jgit.api FetchCommand setDryRun

Introduction

In this page you can find the example usage for org.eclipse.jgit.api FetchCommand setDryRun.

Prototype

public FetchCommand setDryRun(boolean dryRun) 

Source Link

Document

Sets whether the fetch operation should be a dry run

Usage

From source file:net.erdfelt.android.sdkfido.git.internal.InternalGit.java

License:Apache License

@Override
public void pullRemote() throws GitException {
    try {//from   w w  w  .ja  v a  2s  . c o m
        Git git = new Git(repo);
        FetchCommand fetch = git.fetch();
        fetch.setCheckFetchedObjects(false);
        fetch.setRemoveDeletedRefs(true);
        List<RefSpec> specs = new ArrayList<RefSpec>();
        fetch.setRefSpecs(specs);
        fetch.setTimeout(5000);
        fetch.setDryRun(false);
        fetch.setRemote(IGit.REMOTE_NAME);
        fetch.setThin(Transport.DEFAULT_FETCH_THIN);
        fetch.setProgressMonitor(getProgressMonitor());

        FetchResult result = fetch.call();
        if (result.getTrackingRefUpdates().isEmpty()) {
            return;
        }

        GitInfo.infoFetchResults(repo, result);
    } catch (Throwable t) {
        throw new GitException(t.getMessage(), t);
    }
}

From source file:org.ajoberstar.gradle.git.tasks.GitFetch.java

License:Apache License

/**
 * Fetches remote changes into a local Git repository.
 *///from   w w w .  j a v a2  s. c o m
@TaskAction
public void fetch() {
    FetchCommand cmd = getGit().fetch();
    TransportAuthUtil.configure(cmd, this);
    cmd.setTagOpt(getTagOpt());
    cmd.setCheckFetchedObjects(getCheckFetchedObjects());
    cmd.setDryRun(getDryRun());
    cmd.setRefSpecs(getRefspecs());
    cmd.setRemote(getRemote());
    cmd.setRemoveDeletedRefs(getRemoveDeletedRefs());
    cmd.setThin(getThin());
    try {
        cmd.call();
    } catch (InvalidRemoteException e) {
        throw new GradleException("Invalid remote specified: " + getRemote(), e);
    } catch (TransportException e) {
        throw new GradleException("Problem with transport.", e);
    } catch (GitAPIException e) {
        throw new GradleException("Problem with fetch.", e);
    }
    //TODO add progress monitor to log progress to Gradle status bar
}

From source file:org.jboss.forge.addon.git.GitUtilsImpl.java

License:Open Source License

@Override
public FetchResult fetch(final Git git, final String remote, final String refSpec, final int timeout,
        final boolean fsck, final boolean dryRun, final boolean thin, final boolean prune)
        throws GitAPIException {
    FetchCommand fetch = git.fetch();
    fetch.setCheckFetchedObjects(fsck);// w  ww. jav a  2 s  .c om
    fetch.setRemoveDeletedRefs(prune);
    if (refSpec != null)
        fetch.setRefSpecs(new RefSpec(refSpec));
    if (timeout >= 0)
        fetch.setTimeout(timeout);
    fetch.setDryRun(dryRun);
    fetch.setRemote(remote);
    fetch.setThin(thin);
    fetch.setProgressMonitor(new TextProgressMonitor());

    FetchResult result = fetch.call();
    return result;
}

From source file:org.jboss.forge.git.GitUtils.java

License:Open Source License

public static FetchResult fetch(final Git git, final String remote, final String refSpec, final int timeout,
        final boolean fsck, final boolean dryRun, final boolean thin, final boolean prune)
        throws GitAPIException {
    FetchCommand fetch = git.fetch();
    fetch.setCheckFetchedObjects(fsck);//w ww. ja v  a  2  s.c  om
    fetch.setRemoveDeletedRefs(prune);
    if (refSpec != null)
        fetch.setRefSpecs(new RefSpec(refSpec));
    if (timeout >= 0)
        fetch.setTimeout(timeout);
    fetch.setDryRun(dryRun);
    fetch.setRemote(remote);
    fetch.setThin(thin);
    fetch.setProgressMonitor(new TextProgressMonitor());

    FetchResult result = fetch.call();
    return result;
}

From source file:org.ms123.common.git.GitServiceImpl.java

License:Open Source License

private Boolean updateAvailable(Git git) throws Exception {
    FetchCommand fc = git.fetch();
    fc.setDryRun(true);
    fc.setRemote("origin");
    FetchResult fr = null;/*from   ww  w .j av  a  2s .  co m*/
    try {
        fr = fc.call();
    } catch (org.eclipse.jgit.api.errors.InvalidRemoteException e) {
        return false;
    }
    debug("getAdvertisedRefs:" + fr.getAdvertisedRefs());
    debug("getTrackingRefUpdates:" + fr.getTrackingRefUpdates());
    return !fr.getTrackingRefUpdates().isEmpty();
}