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

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

Introduction

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

Prototype

public RepoCommand setIncludedFileReader(IncludedFileReader reader) 

Source Link

Document

Set the IncludedFileReader callback.

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 {//ww  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();
}