use of org.eclipse.jgit.api.AddCommand in project che by eclipse.
the class JGitConnection method add.
@Override
public void add(AddParams params) throws GitException {
AddCommand addCommand = getGit().add().setUpdate(params.isUpdate());
List<String> filePatterns = params.getFilePattern();
if (filePatterns.isEmpty()) {
filePatterns = AddRequest.DEFAULT_PATTERN;
}
filePatterns.forEach(addCommand::addFilepattern);
try {
addCommand.call();
addDeletedFilesToIndex(filePatterns);
} catch (GitAPIException exception) {
throw new GitException(exception.getMessage(), exception);
}
}
use of org.eclipse.jgit.api.AddCommand 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;
}
Aggregations