1 package com.proalpha.pds.gitutils.cherrypick;
3 import java.io.IOException;
4 import java.lang.reflect.InvocationTargetException;
7 import org.eclipse.core.runtime.jobs.ISchedulingRule;
8 import org.eclipse.egit.core.internal.job.RuleUtil;
9 import org.eclipse.jgit.api.errors.GitAPIException;
10 import org.eclipse.jgit.revwalk.RevCommit;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
14 import com.proalpha.git.PaGit;
15 import com.proalpha.git.util.PaIssueExplorer;
16 import com.proalpha.git.util.PaRepository;
17 import com.proalpha.pds.gitutils.Activator;
18 import com.proalpha.pds.gitutils.PreferencesConstants;
24 private List<RevCommit> gatheredCommits;
25 private String repository;
26 private String branch;
30 this.repository = repository;
35 public void run()
throws InvocationTargetException {
37 String repTemp =
null;
40 String remoteBranch =
"";
43 if (!gitServerPath.endsWith(
"/"))
44 gitServerPath = gitServerPath +
'/';
46 remoteBranch = gitServerPath +
"scm/" + this.repository;
48 repTemp = PaRepository.connectRemoteBranch(remoteBranch, this.branch,
'_' + this.repository);
50 logger.debug(
"Remotebranch created as: {}", repTemp);
51 List<RevCommit> commits = PaIssueExplorer.getCommitsOfIssue(repTemp, this.issue);
53 if (logger.isDebugEnabled())
54 for (RevCommit commit : commits) {
55 logger.debug(
"Found commit: {}, message: {}", commit.getName(), commit.getFullMessage());
58 this.gatheredCommits = commits;
60 }
catch (GitAPIException e) {
61 throw new InvocationTargetException(e.getCause() !=
null ? e.getCause() : e);
62 }
catch (IOException e) {
63 throw new InvocationTargetException(e);
66 PaRepository.disconnectRemote(
'_' + this.repository);
67 }
catch (IOException | GitAPIException e) {
68 logger.error(
"Exception while disconnecting remote {}", repTemp, e);
74 public List<RevCommit> getOperationResult() {
75 return gatheredCommits;
78 @SuppressWarnings(
"restriction")
79 public ISchedulingRule getSchedulingRule() {
81 return RuleUtil.getRule(PaGit.getInstance().getGit().getRepository());
82 }
catch (NullPointerException npe) {
static Activator getDefault()