Example usage for org.eclipse.jgit.api.errors PatchApplyException PatchApplyException

List of usage examples for org.eclipse.jgit.api.errors PatchApplyException PatchApplyException

Introduction

In this page you can find the example usage for org.eclipse.jgit.api.errors PatchApplyException PatchApplyException.

Prototype

public PatchApplyException(String message, Throwable cause) 

Source Link

Document

Constructor for PatchApplyException

Usage

From source file:MySmartApply.java

License:Eclipse Distribution License

private File getFile(String path, boolean create) throws PatchApplyException {
    File f = new File(this.local_path + path);
    if (create)//from  w  w w.  jav  a  2  s.  co m
        try {
            File parent = f.getParentFile();
            FileUtils.mkdirs(parent, true);
            FileUtils.createNewFile(f);
        } catch (IOException e) {
            throw new PatchApplyException(MessageFormat.format(JGitText.get().createNewFileFailed, f), e);
        }
    return f;
}

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

License:Apache License

/**
 * Apply a path file to the generated archetype
 * //w  ww.ja v a2  s.  c o m
 * @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");
    }
}