use of org.eclipse.jgit.api.errors.NoFilepatternException in project indy by Commonjava.
the class GitManager method addAndCommitPaths.
public GitManager addAndCommitPaths(final ChangeSummary summary, final Collection<String> paths) throws GitSubsystemException {
lockAnd(me -> {
if (!verifyChangesExist(paths)) {
logger.info("No actual changes in:\n {}\n\nSkipping commit.", join(paths, "\n "));
return this;
}
try {
final AddCommand add = git.add();
final CommitCommand commit = git.commit();
for (final String filepath : paths) {
add.addFilepattern(filepath);
}
logger.info("Adding:\n " + join(paths, "\n ") + "\n\nSummary: " + summary);
add.call();
commit.setMessage(buildMessage(summary, paths)).setAuthor(summary.getUser(), email).call();
} catch (final NoFilepatternException e) {
throw new GitSubsystemException("Cannot add to git: " + e.getMessage(), e);
} catch (final GitAPIException e) {
throw new GitSubsystemException("Cannot add to git: " + e.getMessage(), e);
}
return me;
});
return this;
}
use of org.eclipse.jgit.api.errors.NoFilepatternException in project indy by Commonjava.
the class GitManager method deleteAndCommitPaths.
public GitManager deleteAndCommitPaths(final ChangeSummary summary, final Collection<String> paths) throws GitSubsystemException {
lockAnd(me -> {
try {
RmCommand rm = git.rm();
CommitCommand commit = git.commit();
for (final String path : paths) {
rm = rm.addFilepattern(path);
commit = commit.setOnly(path);
}
logger.info("Deleting:\n " + join(paths, "\n ") + "\n\nSummary: " + summary);
rm.call();
commit.setMessage(buildMessage(summary, paths)).setAuthor(summary.getUser(), email).call();
} catch (final NoFilepatternException e) {
throw new GitSubsystemException("Cannot remove from git: " + e.getMessage(), e);
} catch (final JGitInternalException | GitAPIException e) {
throw new GitSubsystemException("Cannot remove from git: " + e.getMessage(), e);
}
return me;
});
return this;
}
Aggregations