use of org.eclipse.egit.github.core.MergeStatus in project jbpm-work-items by kiegroup.
the class MergePullRequestWorkitemHandler method executeWorkItem.
public void executeWorkItem(WorkItem workItem, WorkItemManager workItemManager) {
try {
Map<String, Object> results = new HashMap<String, Object>();
String repoOwner = (String) workItem.getParameter("RepoOwner");
String repoName = (String) workItem.getParameter("RepoName");
String pullRequestNum = (String) workItem.getParameter("PullRequestNum");
String commitMessage = (String) workItem.getParameter("CommitMessage");
MergeStatus mergeStatus;
if (StringUtils.isNotEmpty(repoOwner) && StringUtils.isNotEmpty(repoName) && StringUtils.isNumeric(pullRequestNum)) {
PullRequestService pullRequestService = auth.getPullRequestService(this.userName, this.password);
RepositoryId repositoryId = new RepositoryId(repoOwner, repoName);
if (pullRequestService.getPullRequest(repositoryId, Integer.parseInt(pullRequestNum)).isMergeable()) {
mergeStatus = pullRequestService.merge(repositoryId, Integer.parseInt(pullRequestNum), commitMessage);
results.put(RESULTS_VALUE, mergeStatus.isMerged());
} else {
results.put(RESULTS_VALUE, false);
}
workItemManager.completeWorkItem(workItem.getId(), results);
} else {
logger.error("Missing repository and pull request info.");
throw new IllegalArgumentException("Missing repository and pull request info.");
}
} catch (Exception e) {
handleException(e);
}
}
Aggregations