use of org.eclipse.jgit.api.CherryPickResult in project camel by apache.
the class GitProducer method doCherryPick.
protected void doCherryPick(Exchange exchange, String operation) throws Exception {
CherryPickResult result = null;
String commitId = null;
try {
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_ID))) {
commitId = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_ID, String.class);
} else {
throw new IllegalArgumentException("Commit id must be specified to execute " + operation);
}
RevWalk walk = new RevWalk(repo);
ObjectId id = repo.resolve(commitId);
RevCommit commit = walk.parseCommit(id);
walk.dispose();
if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
}
result = git.cherryPick().include(commit).call();
} catch (Exception e) {
LOG.error("There was an error in Git " + operation + " operation");
throw e;
}
updateExchange(exchange, result);
}
Aggregations