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

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

Introduction

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

Prototype

@Override
public ApplyResult call() throws GitAPIException, PatchFormatException, PatchApplyException 

Source Link

Document

Executes the ApplyCommand command with all the options and parameters collected by the setter methods (e.g.

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 va 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");
    }
}