Example usage for org.eclipse.jgit.api ApplyCommand setPatch

List of usage examples for org.eclipse.jgit.api ApplyCommand setPatch

Introduction

In this page you can find the example usage for org.eclipse.jgit.api ApplyCommand setPatch.

Prototype

public ApplyCommand setPatch(InputStream in) 

Source Link

Document

Set patch

Usage

From source file:org.jboss.maven.plugins.qstools.ArchetypeSyncMojo.java

License:Apache License

/**
 * Apply a path file to the generated archetype
 * // ww  w .j  a  v  a  2 s .  com
 * @throws IOException
 * @throws GitAPIException
 * @throws PatchApplyException
 * @throws PatchFormatException
 * 
 * @see {@link ArchetypeSyncMojo#applyPatch}
 */
private void applyPatch() throws IOException, PatchApplyException {
    if (this.applyPatch != null) {
        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        Repository repository = builder.findGitDir(new File(baseDir)).build();

        Git git = new Git(repository);
        ApplyCommand applyCommand = git.apply();
        applyCommand.setPatch(new FileInputStream(applyPatch));
        try {
            applyCommand.call();
        } catch (GitAPIException e) {
            throw new PatchApplyException("Can't apply " + applyPatch, e);
        }
        getLog().info("Patch " + applyPatch + " applied");
    }
}