Example usage for org.eclipse.jgit.gitrepo RepoCommand call

List of usage examples for org.eclipse.jgit.gitrepo RepoCommand call

Introduction

In this page you can find the example usage for org.eclipse.jgit.gitrepo RepoCommand call.

Prototype

@Override
public RevCommit call() throws GitAPIException 

Source Link

Usage

From source file:com.googlesource.gerrit.plugins.supermanifest.RepoUpdater.java

License:Apache License

@Override
public void update(GerritRemoteReader reader, ConfigEntry c, String srcRef)
        throws IOException, GitAPIException {
    Repository destRepo = reader.openRepository(c.getDestRepoKey().toString());
    Repository srcRepo = reader.openRepository(c.getSrcRepoKey().toString());

    RepoCommand cmd = new RepoCommand(destRepo);

    if (c.getDestBranch().equals("*")) {
        cmd.setTargetBranch(srcRef.substring(REFS_HEADS.length()));
    } else {/*from  w w w  . ja v a 2  s .  c  o  m*/
        cmd.setTargetBranch(c.getDestBranch());
    }

    InputStream manifestStream = new ByteArrayInputStream(
            Utils.readBlob(srcRepo, srcRef + ":" + c.getXmlPath()));

    cmd.setAuthor(serverIdent).setGroups(c.getGroupsParameter()).setRecordRemoteBranch(true)
            .setRecordSubmoduleLabels(c.isRecordSubmoduleLabels())
            .setIgnoreRemoteFailures(c.ignoreRemoteFailures).setInputStream(manifestStream)
            .setRecommendShallow(true).setRemoteReader(reader).setTargetURI(c.getDestRepoKey().toString())
            .setURI(c.getBaseUri().toString());

    // Must setup a included file reader; the default is to read the file from the filesystem
    // otherwise, which would leak data from the serving machine.
    cmd.setIncludedFileReader(new GerritIncludeReader(srcRepo, srcRef));

    cmd.call();
}