1 package com.proalpha.pds.gitutils.cherrypick;
3 import java.io.IOException;
5 import org.eclipse.jgit.api.errors.GitAPIException;
6 import org.eclipse.jgit.lib.Constants;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
10 import com.proalpha.git.PaGit;
11 import com.proalpha.git.commands.PaIssueConveyanceCommand;
12 import com.proalpha.git.model.PaCherryPickResult;
13 import com.proalpha.git.util.PaRepository;
14 import com.proalpha.pds.gitutils.Activator;
15 import com.proalpha.pds.gitutils.PreferencesConstants;
19 private final Logger logger = LoggerFactory.getLogger(
CherryPick.class);
21 private static final class CherryPickInstanceHolder {
29 return CherryPickInstanceHolder.INSTANCE;
33 private PaCherryPickResult cherryPickResult;
34 private PaIssueConveyanceCommand cherryPickCommand;
37 return cherryPickSettings;
40 public PaCherryPickResult getCherryPickResult() {
41 return cherryPickResult;
44 public void setCherryPickResult(PaCherryPickResult cherryPickResult) {
45 this.cherryPickResult = cherryPickResult;
48 public PaIssueConveyanceCommand getCherryPickCommand() {
49 return cherryPickCommand;
52 public void createCherryPickCommand(
CherryPickSettings settings)
throws IOException, GitAPIException {
54 cherryPickSettings = settings;
55 String remoteBranch =
"";
58 if (!gitServerPath.endsWith(
"/"))
59 gitServerPath = gitServerPath +
'/';
62 remoteBranch = gitServerPath +
"scm/" + cherryPickSettings.getSourceRepoString();
64 String repTemp = PaRepository.connectRemoteBranch(remoteBranch, cherryPickSettings.getSourceBranch(),
'_' + cherryPickSettings.getSourceRepoString());
66 cherryPickCommand = PaGit.getInstance().paIssueConveyenceCommand()
67 .setIssue(cherryPickSettings.getSourceIssue())
68 .setTargetIssue(cherryPickSettings.getTargetIssue())
69 .setSourceRef(repTemp)
70 .setTargetRef(Constants.R_HEADS + cherryPickSettings.getTargetBranch());
81 cherryPickCommand.rollback();
83 PaRepository.disconnectRemote(
'_' + cherryPickSettings.getSourceRepoString());
84 }
catch (IOException | GitAPIException e) {
85 logger.error(
"Exception while disconnecting remote {}", cherryPickCommand.getSourceRef(), e);
97 cherryPickSettings =
null;
98 cherryPickCommand =
null;
99 cherryPickResult =
null;
static Activator getDefault()
void cancelCherryPick(boolean rollback)