Example usage for org.eclipse.jgit.api LsRemoteCommand call

List of usage examples for org.eclipse.jgit.api LsRemoteCommand call

Introduction

In this page you can find the example usage for org.eclipse.jgit.api LsRemoteCommand call.

Prototype

@Override
public Collection<Ref> call()
        throws GitAPIException, InvalidRemoteException, org.eclipse.jgit.api.errors.TransportException 

Source Link

Document

Execute the LsRemote command with all the options and parameters collected by the setter methods (e.g.

Usage

From source file:org.jenkinsci.git.LsRemoteOperation.java

License:Open Source License

public ObjectId call() throws IOException {
    LsRemoteCommand ls = Git.wrap(gitRepo).lsRemote();
    ls.setRemote(repo.getUri());/*from   w  ww.ja  v  a2 s . co  m*/
    String branch = repo.getBranch();
    Collection<Ref> refs;
    try {
        refs = ls.call();
    } catch (IOException e) {
        throw e;
    } catch (Exception e) {
        throw new IOException(e);
    }
    for (Ref ref : refs)
        if (branch.equals(ref.getName()))
            return ref.getObjectId();
    return null;
}