mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-15 01:59:12 -04:00
feat(issue-62): make cherry-pick strategy configurable (#63)
fix https://github.com/kiegroup/git-backporting/issues/62
This commit is contained in:
parent
ead1322c0f
commit
265955dda7
18 changed files with 312 additions and 58 deletions
|
@ -105,9 +105,20 @@ export default class GitCLIService {
|
|||
* @param cwd repository in which the sha should be cherry picked to
|
||||
* @param sha commit sha
|
||||
*/
|
||||
async cherryPick(cwd: string, sha: string): Promise<void> {
|
||||
async cherryPick(cwd: string, sha: string, strategy = "recursive", strategyOption = "theirs"): Promise<void> {
|
||||
this.logger.info(`Cherry picking ${sha}.`);
|
||||
await this.git(cwd).raw(["cherry-pick", "-m", "1", "--strategy=recursive", "--strategy-option=theirs", sha]);
|
||||
|
||||
const options = ["cherry-pick", "-m", "1", `--strategy=${strategy}`, `--strategy-option=${strategyOption}`, sha];
|
||||
try {
|
||||
await this.git(cwd).raw(options);
|
||||
} catch(error) {
|
||||
const diff = await this.git(cwd).diff();
|
||||
if (diff) {
|
||||
throw new Error(`${error}\r\nShowing git diff:\r\n` + diff);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue