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

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

Introduction

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

Prototype

public RepoCommand setTargetBranch(String branch) 

Source Link

Document

Set target branch.

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   ww w  .  j  a  va  2s .  co  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();
}