diff --git a/README.md b/README.md index 8b8c7f9..a652708 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ This tool comes with some inputs that allow users to override the default behavi | Backport Branch Names | --bp-branch-name | N | Comma separated lists of the backporting pull request branch names, if they exceeds 250 chars they will be truncated | bp-{target-branch}-{sha1}...{shaN} | | Labels | --labels | N | Provide custom labels to be added to the backporting pull request | [] | | Inherit labels | --inherit-labels | N | If enabled inherit lables from the original pull request | false | -| No squash | --no-squash | N | If provided the backporting will try to backport all pull request commits without squashing | false | +| No squash | --no-squash | N | If false only cherry-pick the merged commit, if true cherry-pick all the commits from the pull request. Always true if the pull request has not been merged. | true if the pull request was merged, false if it was squashed | | Strategy | --strategy | N | Cherry pick merging strategy, see [git-merge](https://git-scm.com/docs/git-merge#_merge_strategies) doc for all possible values | "recursive" | | Strategy Option | --strategy-option | N | Cherry pick merging strategy option, see [git-merge](https://git-scm.com/docs/git-merge#_merge_strategies) doc for all possible values | "theirs" | | Cherry-pick Options | --cherry-pick-options | N | Additional cherry-pick options, see [git-cherry-pick](https://git-scm.com/docs/git-cherry-pick) doc for all possible values | "theirs" | diff --git a/action.yml b/action.yml index b157e59..e1f7b4a 100644 --- a/action.yml +++ b/action.yml @@ -85,10 +85,10 @@ inputs: default: "false" no-squash: description: > - If set to true the tool will backport all commits as part of the pull request - instead of the suqashed one + If false only cherry-pick the merged commit, if true cherry-pick all the commits from the pull request. + Always true if the pull request has not been merged. + Defaults to true if the pull request was merged, false if it was squashed. required: false - default: "false" strategy: description: Cherry-pick merge strategy required: false diff --git a/dist/cli/index.js b/dist/cli/index.js index c5c8f0b..e70838e 100755 --- a/dist/cli/index.js +++ b/dist/cli/index.js @@ -65,7 +65,7 @@ class ArgsParser { inheritReviewers: this.getOrDefault(args.inheritReviewers, true), labels: this.getOrDefault(args.labels, []), inheritLabels: this.getOrDefault(args.inheritLabels, false), - squash: this.getOrDefault(args.squash, true), + squash: this.getOrDefault(args.squash), strategy: this.getOrDefault(args.strategy), strategyOption: this.getOrDefault(args.strategyOption), cherryPickOptions: this.getOrDefault(args.cherryPickOptions), @@ -107,7 +107,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getAsBooleanOrDefault = exports.getAsSemicolonSeparatedList = exports.getAsCommaSeparatedList = exports.getAsCleanedCommaSeparatedList = exports.getOrUndefined = exports.readConfigFile = exports.parseArgs = void 0; +exports.getAsInvertedBooleanOrUndefined = exports.getAsBooleanOrDefault = exports.getAsSemicolonSeparatedList = exports.getAsCommaSeparatedList = exports.getAsCleanedCommaSeparatedList = exports.getOrUndefined = exports.readConfigFile = exports.parseArgs = void 0; const fs = __importStar(__nccwpck_require__(7147)); /** * Parse the input configuation string as json object and @@ -163,6 +163,11 @@ function getAsBooleanOrDefault(value) { return trimmed !== "" ? trimmed.toLowerCase() === "true" : undefined; } exports.getAsBooleanOrDefault = getAsBooleanOrDefault; +function getAsInvertedBooleanOrUndefined(value) { + const trimmed = value.trim(); + return trimmed !== "" ? !(trimmed.toLowerCase() === "true") : undefined; +} +exports.getAsInvertedBooleanOrUndefined = getAsInvertedBooleanOrUndefined; /***/ }), @@ -203,7 +208,7 @@ class CLIArgsParser extends args_parser_1.default { .option("--no-inherit-reviewers", "if provided and reviewers option is empty then inherit them from original pull request") .option("--labels ", "comma separated list of labels to be assigned to the backported pull request", args_utils_1.getAsCommaSeparatedList) .option("--inherit-labels", "if true the backported pull request will inherit labels from the original one") - .option("--no-squash", "if provided the tool will backport all commits as part of the pull request") + .option("--no-squash", "If false only cherry-pick the merged commit, if true cherry-pick all the commits from the pull request. Always true if the pull request has not been merged. Defaults to true if the pull request was merged, false if it was squashed", undefined) .option("--strategy ", "cherry-pick merge strategy, default to 'recursive'", undefined) .option("--strategy-option ", "cherry-pick merge strategy option, default to 'theirs'") .option("--cherry-pick-options ", "additional cherry-pick options") @@ -803,13 +808,34 @@ class GitHubClient { getDefaultGitEmail() { return "noreply@github.com"; } - async getPullRequest(owner, repo, prNumber, squash = true) { + async getPullRequest(owner, repo, prNumber, squash) { this.logger.debug(`Fetching pull request ${owner}/${repo}/${prNumber}`); const { data } = await this.octokit.rest.pulls.get({ owner: owner, repo: repo, pull_number: prNumber, }); + if (data.state == "open") { + if (squash == true) { + this.logger.debug(`no-squash force to true because the pull request is open`); + } + squash = false; + } + else if (squash === undefined) { + const commit_sha = data.merge_commit_sha; + let commit = await this.octokit.rest.git.getCommit({ + owner: owner, + repo: repo, + commit_sha: commit_sha, + }); + squash = commit.data.parents.length == 1; + if (squash === true) { + this.logger.debug(`no-squash set to false because the pull request was merged as ${commit_sha} which is a not a merge commit (one parent)`); + } + else { + this.logger.debug(`no-squash set to true because the pull request was merged as ${commit_sha} which is a merge commit (more than one parent)`); + } + } const commits = []; if (!squash) { // fetch all commits @@ -827,7 +853,7 @@ class GitHubClient { } return this.mapper.mapPullRequest(data, commits); } - async getPullRequestFromUrl(prUrl, squash = true) { + async getPullRequestFromUrl(prUrl, squash) { const { owner, project, id } = this.extractPullRequestData(prUrl); return this.getPullRequest(owner, project, id, squash); } @@ -1038,9 +1064,10 @@ class GitLabClient { } // READ // example: /api/v4/projects/%2Fbackporting-example/merge_requests/1 - async getPullRequest(namespace, repo, mrNumber, squash = true) { + async getPullRequest(namespace, repo, mrNumber, squash) { const projectId = this.getProjectId(namespace, repo); const { data } = await this.client.get(`/projects/${projectId}/merge_requests/${mrNumber}`); + // TBD ??? const commits = []; if (!squash) { // fetch all commits @@ -1055,7 +1082,7 @@ class GitLabClient { } return this.mapper.mapPullRequest(data, commits); } - getPullRequestFromUrl(mrUrl, squash = true) { + getPullRequestFromUrl(mrUrl, squash) { const { namespace, project, id } = this.extractMergeRequestData(mrUrl); return this.getPullRequest(namespace, project, id, squash); } diff --git a/dist/gha/index.js b/dist/gha/index.js index 4295ee8..f48eb40 100755 --- a/dist/gha/index.js +++ b/dist/gha/index.js @@ -65,7 +65,7 @@ class ArgsParser { inheritReviewers: this.getOrDefault(args.inheritReviewers, true), labels: this.getOrDefault(args.labels, []), inheritLabels: this.getOrDefault(args.inheritLabels, false), - squash: this.getOrDefault(args.squash, true), + squash: this.getOrDefault(args.squash), strategy: this.getOrDefault(args.strategy), strategyOption: this.getOrDefault(args.strategyOption), cherryPickOptions: this.getOrDefault(args.cherryPickOptions), @@ -107,7 +107,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getAsBooleanOrDefault = exports.getAsSemicolonSeparatedList = exports.getAsCommaSeparatedList = exports.getAsCleanedCommaSeparatedList = exports.getOrUndefined = exports.readConfigFile = exports.parseArgs = void 0; +exports.getAsInvertedBooleanOrUndefined = exports.getAsBooleanOrDefault = exports.getAsSemicolonSeparatedList = exports.getAsCommaSeparatedList = exports.getAsCleanedCommaSeparatedList = exports.getOrUndefined = exports.readConfigFile = exports.parseArgs = void 0; const fs = __importStar(__nccwpck_require__(7147)); /** * Parse the input configuation string as json object and @@ -163,6 +163,11 @@ function getAsBooleanOrDefault(value) { return trimmed !== "" ? trimmed.toLowerCase() === "true" : undefined; } exports.getAsBooleanOrDefault = getAsBooleanOrDefault; +function getAsInvertedBooleanOrUndefined(value) { + const trimmed = value.trim(); + return trimmed !== "" ? !(trimmed.toLowerCase() === "true") : undefined; +} +exports.getAsInvertedBooleanOrUndefined = getAsInvertedBooleanOrUndefined; /***/ }), @@ -206,7 +211,7 @@ class GHAArgsParser extends args_parser_1.default { inheritReviewers: !(0, args_utils_1.getAsBooleanOrDefault)((0, core_1.getInput)("no-inherit-reviewers")), labels: (0, args_utils_1.getAsCommaSeparatedList)((0, core_1.getInput)("labels")), inheritLabels: (0, args_utils_1.getAsBooleanOrDefault)((0, core_1.getInput)("inherit-labels")), - squash: !(0, args_utils_1.getAsBooleanOrDefault)((0, core_1.getInput)("no-squash")), + squash: (0, args_utils_1.getAsInvertedBooleanOrUndefined)((0, core_1.getInput)("no-squash")), strategy: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("strategy")), strategyOption: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("strategy-option")), cherryPickOptions: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("cherry-pick-options")), @@ -770,13 +775,34 @@ class GitHubClient { getDefaultGitEmail() { return "noreply@github.com"; } - async getPullRequest(owner, repo, prNumber, squash = true) { + async getPullRequest(owner, repo, prNumber, squash) { this.logger.debug(`Fetching pull request ${owner}/${repo}/${prNumber}`); const { data } = await this.octokit.rest.pulls.get({ owner: owner, repo: repo, pull_number: prNumber, }); + if (data.state == "open") { + if (squash == true) { + this.logger.debug(`no-squash force to true because the pull request is open`); + } + squash = false; + } + else if (squash === undefined) { + const commit_sha = data.merge_commit_sha; + let commit = await this.octokit.rest.git.getCommit({ + owner: owner, + repo: repo, + commit_sha: commit_sha, + }); + squash = commit.data.parents.length == 1; + if (squash === true) { + this.logger.debug(`no-squash set to false because the pull request was merged as ${commit_sha} which is a not a merge commit (one parent)`); + } + else { + this.logger.debug(`no-squash set to true because the pull request was merged as ${commit_sha} which is a merge commit (more than one parent)`); + } + } const commits = []; if (!squash) { // fetch all commits @@ -794,7 +820,7 @@ class GitHubClient { } return this.mapper.mapPullRequest(data, commits); } - async getPullRequestFromUrl(prUrl, squash = true) { + async getPullRequestFromUrl(prUrl, squash) { const { owner, project, id } = this.extractPullRequestData(prUrl); return this.getPullRequest(owner, project, id, squash); } @@ -1005,9 +1031,10 @@ class GitLabClient { } // READ // example: /api/v4/projects/%2Fbackporting-example/merge_requests/1 - async getPullRequest(namespace, repo, mrNumber, squash = true) { + async getPullRequest(namespace, repo, mrNumber, squash) { const projectId = this.getProjectId(namespace, repo); const { data } = await this.client.get(`/projects/${projectId}/merge_requests/${mrNumber}`); + // TBD ??? const commits = []; if (!squash) { // fetch all commits @@ -1022,7 +1049,7 @@ class GitLabClient { } return this.mapper.mapPullRequest(data, commits); } - getPullRequestFromUrl(mrUrl, squash = true) { + getPullRequestFromUrl(mrUrl, squash) { const { namespace, project, id } = this.extractMergeRequestData(mrUrl); return this.getPullRequest(namespace, project, id, squash); } diff --git a/src/service/args/args-parser.ts b/src/service/args/args-parser.ts index 8a45370..75c86f0 100644 --- a/src/service/args/args-parser.ts +++ b/src/service/args/args-parser.ts @@ -43,7 +43,7 @@ export default abstract class ArgsParser { inheritReviewers: this.getOrDefault(args.inheritReviewers, true), labels: this.getOrDefault(args.labels, []), inheritLabels: this.getOrDefault(args.inheritLabels, false), - squash: this.getOrDefault(args.squash, true), + squash: this.getOrDefault(args.squash), strategy: this.getOrDefault(args.strategy), strategyOption: this.getOrDefault(args.strategyOption), cherryPickOptions: this.getOrDefault(args.cherryPickOptions), diff --git a/src/service/args/args-utils.ts b/src/service/args/args-utils.ts index 9f6165c..0acc31d 100644 --- a/src/service/args/args-utils.ts +++ b/src/service/args/args-utils.ts @@ -53,4 +53,9 @@ export function getAsSemicolonSeparatedList(value: string): string[] | undefined export function getAsBooleanOrDefault(value: string): boolean | undefined { const trimmed = value.trim(); return trimmed !== "" ? trimmed.toLowerCase() === "true" : undefined; -} \ No newline at end of file +} + +export function getAsInvertedBooleanOrUndefined(value: string): boolean | undefined { + const trimmed = value.trim(); + return trimmed !== "" ? !(trimmed.toLowerCase() === "true") : undefined; +} diff --git a/src/service/args/args.types.ts b/src/service/args/args.types.ts index fa14a4a..0e251f2 100644 --- a/src/service/args/args.types.ts +++ b/src/service/args/args.types.ts @@ -22,7 +22,7 @@ export interface Args { inheritReviewers?: boolean, // if true and reviewers == [] then inherit reviewers from original pr labels?: string[], // backport pr labels inheritLabels?: boolean, // if true inherit labels from original pr - squash?: boolean, // if false use squashed/merged commit otherwise backport all commits as part of the pr + squash?: boolean, strategy?: string, // cherry-pick merge strategy strategyOption?: string, // cherry-pick merge strategy option cherryPickOptions?: string, // additional cherry-pick options diff --git a/src/service/args/cli/cli-args-parser.ts b/src/service/args/cli/cli-args-parser.ts index 995e63f..487e365 100644 --- a/src/service/args/cli/cli-args-parser.ts +++ b/src/service/args/cli/cli-args-parser.ts @@ -28,7 +28,7 @@ export default class CLIArgsParser extends ArgsParser { .option("--no-inherit-reviewers", "if provided and reviewers option is empty then inherit them from original pull request") .option("--labels ", "comma separated list of labels to be assigned to the backported pull request", getAsCommaSeparatedList) .option("--inherit-labels", "if true the backported pull request will inherit labels from the original one") - .option("--no-squash", "if provided the tool will backport all commits as part of the pull request") + .option("--no-squash", "If false only cherry-pick the merged commit, if true cherry-pick all the commits from the pull request. Always true if the pull request has not been merged. Defaults to true if the pull request was merged, false if it was squashed", undefined) .option("--strategy ", "cherry-pick merge strategy, default to 'recursive'", undefined) .option("--strategy-option ", "cherry-pick merge strategy option, default to 'theirs'") .option("--cherry-pick-options ", "additional cherry-pick options") diff --git a/src/service/args/gha/gha-args-parser.ts b/src/service/args/gha/gha-args-parser.ts index d8dfdcf..9ee5f8a 100644 --- a/src/service/args/gha/gha-args-parser.ts +++ b/src/service/args/gha/gha-args-parser.ts @@ -1,7 +1,7 @@ import ArgsParser from "@bp/service/args/args-parser"; import { Args } from "@bp/service/args/args.types"; import { getInput } from "@actions/core"; -import { getAsBooleanOrDefault, getAsCleanedCommaSeparatedList, getAsCommaSeparatedList, getAsSemicolonSeparatedList, getOrUndefined, readConfigFile } from "@bp/service/args/args-utils"; +import { getAsBooleanOrDefault, getAsInvertedBooleanOrUndefined, getAsCleanedCommaSeparatedList, getAsCommaSeparatedList, getAsSemicolonSeparatedList, getOrUndefined, readConfigFile } from "@bp/service/args/args-utils"; export default class GHAArgsParser extends ArgsParser { @@ -31,7 +31,7 @@ export default class GHAArgsParser extends ArgsParser { inheritReviewers: !getAsBooleanOrDefault(getInput("no-inherit-reviewers")), labels: getAsCommaSeparatedList(getInput("labels")), inheritLabels: getAsBooleanOrDefault(getInput("inherit-labels")), - squash: !getAsBooleanOrDefault(getInput("no-squash")), + squash: getAsInvertedBooleanOrUndefined(getInput("no-squash")), strategy: getOrUndefined(getInput("strategy")), strategyOption: getOrUndefined(getInput("strategy-option")), cherryPickOptions: getOrUndefined(getInput("cherry-pick-options")), diff --git a/src/service/git/git-client.ts b/src/service/git/git-client.ts index c9d0f10..3df6a0e 100644 --- a/src/service/git/git-client.ts +++ b/src/service/git/git-client.ts @@ -25,7 +25,7 @@ import { BackportPullRequest, GitClientType, GitPullRequest } from "@bp/service/ * @param squash if true keep just one single commit, otherwise get the full list * @returns {Promise} */ - getPullRequest(owner: string, repo: string, prNumber: number, squash: boolean): Promise; + getPullRequest(owner: string, repo: string, prNumber: number, squash: boolean | undefined): Promise; /** * Get a pull request object from the underneath git service @@ -33,7 +33,7 @@ import { BackportPullRequest, GitClientType, GitPullRequest } from "@bp/service/ * @param squash if true keep just one single commit, otherwise get the full list * @returns {Promise} */ - getPullRequestFromUrl(prUrl: string, squash: boolean): Promise; + getPullRequestFromUrl(prUrl: string, squash: boolean | undefined): Promise; // WRITE diff --git a/src/service/git/github/github-client.ts b/src/service/git/github/github-client.ts index 40f1831..b6397ad 100644 --- a/src/service/git/github/github-client.ts +++ b/src/service/git/github/github-client.ts @@ -37,7 +37,7 @@ export default class GitHubClient implements GitClient { return "noreply@github.com"; } - async getPullRequest(owner: string, repo: string, prNumber: number, squash = true): Promise { + async getPullRequest(owner: string, repo: string, prNumber: number, squash: boolean | undefined): Promise { this.logger.debug(`Fetching pull request ${owner}/${repo}/${prNumber}`); const { data } = await this.octokit.rest.pulls.get({ owner: owner, @@ -45,6 +45,26 @@ export default class GitHubClient implements GitClient { pull_number: prNumber, }); + if (data.state == "open") { + if (squash == true) { + this.logger.debug(`no-squash force to true because the pull request is open`); + } + squash = false + } else if (squash === undefined) { + const commit_sha = data.merge_commit_sha + let commit = await this.octokit.rest.git.getCommit({ + owner: owner, + repo: repo, + commit_sha: (commit_sha as string), + }) + squash = commit.data.parents.length == 1; + if (squash === true) { + this.logger.debug(`no-squash set to false because the pull request was merged as ${commit_sha} which is a not a merge commit (one parent)`); + } else { + this.logger.debug(`no-squash set to true because the pull request was merged as ${commit_sha} which is a merge commit (more than one parent)`); + } + } + const commits: string[] = []; if (!squash) { // fetch all commits @@ -64,7 +84,7 @@ export default class GitHubClient implements GitClient { return this.mapper.mapPullRequest(data as PullRequest, commits); } - async getPullRequestFromUrl(prUrl: string, squash = true): Promise { + async getPullRequestFromUrl(prUrl: string, squash: boolean | undefined): Promise { const { owner, project, id } = this.extractPullRequestData(prUrl); return this.getPullRequest(owner, project, id, squash); } @@ -156,4 +176,4 @@ export default class GitHubClient implements GitClient { id: parseInt(prUrl.substring(prUrl.lastIndexOf("/") + 1, prUrl.length)), }; } -} \ No newline at end of file +} diff --git a/src/service/git/gitlab/gitlab-client.ts b/src/service/git/gitlab/gitlab-client.ts index c874b70..a26f62e 100644 --- a/src/service/git/gitlab/gitlab-client.ts +++ b/src/service/git/gitlab/gitlab-client.ts @@ -45,10 +45,12 @@ export default class GitLabClient implements GitClient { // READ // example: /api/v4/projects/%2Fbackporting-example/merge_requests/1 - async getPullRequest(namespace: string, repo: string, mrNumber: number, squash = true): Promise { + async getPullRequest(namespace: string, repo: string, mrNumber: number, squash: boolean | undefined): Promise { const projectId = this.getProjectId(namespace, repo); const { data } = await this.client.get(`/projects/${projectId}/merge_requests/${mrNumber}`); + // TBD ??? + const commits: string[] = []; if (!squash) { // fetch all commits @@ -65,7 +67,7 @@ export default class GitLabClient implements GitClient { return this.mapper.mapPullRequest(data as MergeRequestSchema, commits); } - getPullRequestFromUrl(mrUrl: string, squash = true): Promise { + getPullRequestFromUrl(mrUrl: string, squash: boolean | undefined): Promise { const { namespace, project, id } = this.extractMergeRequestData(mrUrl); return this.getPullRequest(namespace, project, id, squash); } @@ -206,4 +208,4 @@ export default class GitLabClient implements GitClient { // e.g., %2F return encodeURIComponent(`${namespace}/${repo}`); } -} \ No newline at end of file +} diff --git a/test/service/args/cli/cli-args-parser.test.ts b/test/service/args/cli/cli-args-parser.test.ts index b49c466..990357f 100644 --- a/test/service/args/cli/cli-args-parser.test.ts +++ b/test/service/args/cli/cli-args-parser.test.ts @@ -78,7 +78,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expect(args.labels).toEqual([]); expect(args.inheritLabels).toEqual(false); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); @@ -108,7 +108,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expect(args.labels).toEqual([]); expect(args.inheritLabels).toEqual(false); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); @@ -140,7 +140,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expect(args.labels).toEqual([]); expect(args.inheritLabels).toEqual(false); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); @@ -170,7 +170,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expect(args.labels).toEqual([]); expect(args.inheritLabels).toEqual(false); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); @@ -209,7 +209,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expect(args.labels).toEqual([]); expect(args.inheritLabels).toEqual(false); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); @@ -266,7 +266,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(false); expectArrayEqual(args.labels!, ["cherry-pick :cherries:", "another spaced label"]); expect(args.inheritLabels).toEqual(true); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); @@ -296,7 +296,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expectArrayEqual(args.labels!, ["cherry-pick :cherries:"]); expect(args.inheritLabels).toEqual(true); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); @@ -355,7 +355,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expectArrayEqual(args.labels!, ["cherry-pick :cherries:"]); expect(args.inheritLabels).toEqual(true); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); @@ -423,7 +423,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expect(args.labels).toEqual([]); expect(args.inheritLabels).toEqual(false); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual("ort"); expect(args.strategyOption).toEqual("ours"); expect(args.cherryPickOptions).toEqual("--allow-empty -x"); @@ -457,7 +457,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expect(args.labels).toEqual([]); expect(args.inheritLabels).toEqual(false); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expectArrayEqual(args.comments!,["first comment", "second comment"]); }); @@ -487,7 +487,7 @@ describe("cli args parser", () => { expect(args.inheritReviewers).toEqual(true); expect(args.labels).toEqual([]); expect(args.inheritLabels).toEqual(false); - expect(args.squash).toEqual(true); + expect(args.squash).toEqual(undefined); expect(args.strategy).toEqual(undefined); expect(args.strategyOption).toEqual(undefined); expect(args.cherryPickOptions).toEqual(undefined); diff --git a/test/service/git/github/github-client.test.ts b/test/service/git/github/github-client.test.ts index 97fc996..35a4d5c 100644 --- a/test/service/git/github/github-client.test.ts +++ b/test/service/git/github/github-client.test.ts @@ -22,7 +22,7 @@ describe("github service", () => { }); test("get pull request: success", async () => { - const res: GitPullRequest = await gitClient.getPullRequest(TARGET_OWNER, REPO, MERGED_PR_FIXTURE.number); + const res: GitPullRequest = await gitClient.getPullRequest(TARGET_OWNER, REPO, MERGED_PR_FIXTURE.number, true); expect(res.sourceRepo).toEqual({ owner: "fork", project: "reponame", diff --git a/test/service/git/gitlab/gitlab-client.test.ts b/test/service/git/gitlab/gitlab-client.test.ts index b33ab9e..38deda1 100644 --- a/test/service/git/gitlab/gitlab-client.test.ts +++ b/test/service/git/gitlab/gitlab-client.test.ts @@ -31,7 +31,7 @@ describe("github service", () => { }); test("get merged pull request", async () => { - const res: GitPullRequest = await gitClient.getPullRequest("superuser", "backporting-example", 1); + const res: GitPullRequest = await gitClient.getPullRequest("superuser", "backporting-example", 1, true); // check content expect(res.sourceRepo).toEqual({ @@ -56,7 +56,7 @@ describe("github service", () => { }); test("get open pull request", async () => { - const res: GitPullRequest = await gitClient.getPullRequest("superuser", "backporting-example", 2); + const res: GitPullRequest = await gitClient.getPullRequest("superuser", "backporting-example", 2, true); expect(res.sourceRepo).toEqual({ owner: "superuser", project: "backporting-example", @@ -325,7 +325,7 @@ describe("github service", () => { }); test("get pull request for nested namespaces", async () => { - const res: GitPullRequest = await gitClient.getPullRequestFromUrl("https://my.gitlab.host.com/mysuperorg/6/mysuperproduct/mysuperunit/backporting-example/-/merge_requests/4"); + const res: GitPullRequest = await gitClient.getPullRequestFromUrl("https://my.gitlab.host.com/mysuperorg/6/mysuperproduct/mysuperunit/backporting-example/-/merge_requests/4", true); // check content expect(res.sourceRepo).toEqual({