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

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

Introduction

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

Prototype

public RepoCommand setAuthor(PersonIdent author) 

Source Link

Document

Set the author/committer for the bare repository commit.

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 .  c  om*/
        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();
}