17 Commits
v4.8.6 ... main

Author SHA1 Message Date
dependabot[bot]
617d051801 build(deps): bump axios from 1.12.0 to 1.13.5 (#184)
Bumps [axios](https://github.com/axios/axios) from 1.12.0 to 1.13.5.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.12.0...v1.13.5)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.13.5
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-14 13:16:07 +01:00
dependabot[bot]
84086ccb67 build(deps): bump qs and express (#180)
Bumps [qs](https://github.com/ljharb/qs) and [express](https://github.com/expressjs/express). These dependencies needed to be updated together.

Updates `qs` from 6.13.0 to 6.14.1
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.13.0...v6.14.1)

Updates `express` from 4.21.2 to 4.22.1
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/v4.22.1/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.21.2...v4.22.1)

---
updated-dependencies:
- dependency-name: qs
  dependency-version: 6.14.1
  dependency-type: indirect
- dependency-name: express
  dependency-version: 4.22.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-25 18:48:22 +01:00
dependabot[bot]
c93b7d67ea build(deps): bump lodash from 4.17.21 to 4.17.23 (#183)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-25 18:45:06 +01:00
oliverpool
430523aefa feat(#181): reconstruct script in failure comment (#182)
* feat(#181): reconstruct script in failure comment

* test: ensure steps after failure are still present
2026-01-25 18:39:11 +01:00
github-actions[bot]
baae3fe1e3 chore: release v4.8.7 (#179)
* chore: release v4.8.7

* docs: remove reverts from changelog

Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>

* docs: fix changelog links

Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>

---------

Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
Co-authored-by: Create or Update Pull Request Action <create-or-update-pull-request@users.noreply.github.com>
Co-authored-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-12-11 17:57:58 +01:00
Andrea Lamparelli
42d5ca8288 fix: override conventional-changelog-conventionalcommits (#178)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-12-11 17:42:17 +01:00
Andrea Lamparelli
39b6b1515b fix: throw error when trying to backport single undefined commit (#177)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-12-08 16:54:50 +01:00
Andrea Lamparelli
1a106f1eb6 build(deps): bump @commintlint and release-it (#175)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-11-28 11:39:49 +01:00
Andrea Lamparelli
89105bb7d3 build(deps): bump glob to 10.5.0 and fix commit parser (#174)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-11-28 11:28:06 +01:00
Andrea Lamparelli
23049ae554 Revert "build(deps): downgrade @release-it/conventional-changelog to 10.0.1 (#170)" (#172)
This reverts commit 3a675f142c.
2025-11-26 10:40:08 +01:00
Andrea Lamparelli
3a675f142c build(deps): downgrade @release-it/conventional-changelog to 10.0.1 (#170)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-11-26 10:34:20 +01:00
Andrea Lamparelli
3799908281 build(deps): bump jest to 30.2.0 (#167)
Signed-off-by: Andrea Lamparelli <noreply@github.com>
2025-11-17 18:18:26 +01:00
Andrea Lamparelli
d5c509d220 ci: remove node 16 and add 22 and 24 (#168)
Signed-off-by: Andrea Lamparelli <noreply@github.com>
Co-authored-by: Andrea Lamparelli <noreply@github.com>
2025-11-17 18:15:33 +01:00
Andrea Lamparelli
c639b193bb build(deps): audit fix (#164)
Signed-off-by: Andrea Lamparelli <noreply@github.com>
2025-11-17 17:49:17 +01:00
Andrea Lamparelli
a31f1f1976 build(deps): bump jest to 29.7.0 (#166)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-11-17 17:45:43 +01:00
Andrea Lamparelli
179191633c build(deps): rebuild after bump axios to 1.12.0 (#165)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-11-17 15:08:21 +01:00
dependabot[bot]
00e591a1e6 build(deps): bump axios from 1.8.4 to 1.12.0 (#163)
Bumps [axios](https://github.com/axios/axios) from 1.8.4 to 1.12.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.8.4...v1.12.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.12.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-15 09:19:36 +02:00
28 changed files with 13171 additions and 7070 deletions

View File

@@ -13,7 +13,7 @@ jobs:
name: ${{ matrix.os }} - node ${{ matrix.node-version }}
strategy:
matrix:
node-version: [16, 18, 20]
node-version: [18, 20, 22, 24]
os: [ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.os }}

View File

@@ -18,7 +18,7 @@ jobs:
name: ${{ matrix.os }} - node ${{ matrix.node-version }}
strategy:
matrix:
node-version: [16, 18, 20]
node-version: [18, 20, 22, 24]
os: [ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.os }}

View File

@@ -1,5 +1,12 @@
# Changelog
## [4.8.7](///compare/v4.8.6...v4.8.7) (2025-12-11)
### Bug Fixes
* override conventional-changelog-conventionalcommits ([#178](https://github.com/kiegroup/git-backporting/issues/178)) ([42d5ca8](https://github.com/kiegroup/git-backporting/commit/42d5ca8288b2af94b1d47f7fe5cb153ae2480822))
* throw error when trying to backport single undefined commit ([#177](https://github.com/kiegroup/git-backporting/issues/177)) ([39b6b15](https://github.com/kiegroup/git-backporting/commit/39b6b1515be29d0fc5b48f2a85342217e3c22ce8))
## <small>4.8.6 (2025-09-04)</small>
* ci: bump node version to 20 for ci workflows (#161) ([c5ce1d4](https://github.com/kiegroup/git-backporting/commit/c5ce1d4)), closes [#161](https://github.com/kiegroup/git-backporting/issues/161)

902
dist/cli/index.js vendored

File diff suppressed because it is too large Load Diff

900
dist/gha/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,8 @@ const jestConfig: Config.InitialOptions = {
"^@bp/(.*)$": "<rootDir>/src/$1",
},
clearMocks: true,
resetMocks: true,
restoreMocks: false,
resetMocks: false,
modulePathIgnorePatterns: ["<rootDir>/build/", "<rootDir>/dist/"],
coveragePathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/test/", "<rootDir>/build/", "<rootDir>/dist/"]
};

14798
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@kie/git-backporting",
"version": "4.8.6",
"version": "4.8.7",
"description": "Git backporting is a tool to execute automatic pull request git backporting.",
"author": "",
"license": "MIT",
@@ -50,8 +50,8 @@
},
"homepage": "https://github.com/kiegroup/git-backporting#readme",
"devDependencies": {
"@commitlint/cli": "^17.4.0",
"@commitlint/config-conventional": "^17.4.0",
"@commitlint/cli": "^20.1.0",
"@commitlint/config-conventional": "^20.0.0",
"@gitbeaker/rest": "^39.1.0",
"@kie/mock-github": "^1.1.0",
"@octokit/webhooks-types": "^6.8.0",
@@ -62,13 +62,14 @@
"@typescript-eslint/eslint-plugin": "^5.47.0",
"@typescript-eslint/parser": "^5.47.0",
"@vercel/ncc": "^0.36.0",
"conventional-commits-parser": "^6.2.0",
"eslint": "^8.30.0",
"husky": "^8.0.2",
"jest": "^29.0.0",
"jest": "^30.0.0",
"jest-sonar-reporter": "^2.0.0",
"release-it": "^19.0.2",
"release-it": "^19.0.6",
"semver": "^7.3.8",
"ts-jest": "^29.0.0",
"ts-jest": "^29.4.5",
"ts-node": "^10.8.1",
"tsc-alias": "^1.8.2",
"tsconfig-paths": "^4.1.0",
@@ -82,5 +83,8 @@
"fs-extra": "^11.1.0",
"https": "^1.0.0",
"simple-git": "^3.15.1"
},
"overrides": {
"conventional-changelog-conventionalcommits": "^8.0.0"
}
}

View File

@@ -139,7 +139,10 @@ export default class PullRequestConfigsParser extends ConfigsParser {
let backportBranch = bpBranchNames.length > 1 ? bpBranchNames[idx] : bpBranchNames[0];
if (backportBranch === undefined || backportBranch.trim() === "") {
// for each commit takes the first 7 chars that are enough to uniquely identify them in most of the projects
const concatenatedCommits: string = originalPullRequest.commits!.map(c => c.slice(0, 7)).join("-");
const concatenatedCommits: string = originalPullRequest.commits!.filter(c => c).map(c => c.slice(0, 7)).join("-");
if (concatenatedCommits === "") {
throw new Error("Missing commits, stopping the backporting!");
}
backportBranch = `bp-${tb}-${concatenatedCommits}`;
} else if (bpBranchNames.length == 1 && targetBranches.length > 1) {
// multiple targets and single custom backport branch name we need to differentiate branch names

View File

@@ -37,7 +37,12 @@ export default class GitHubMapper implements GitResponseMapper<PullRequest, "ope
private getSha(pr: PullRequest) {
// if pr is open use latest commit sha otherwise use merge_commit_sha
return pr.state === "open" ? [pr.head.sha] : [pr.merge_commit_sha as string];
const sha = pr.state === "open" ? pr.head.sha : pr.merge_commit_sha as string;
if (!sha) {
throw new Error("Trying to backport a single squashed/merged commit that does not exist! Aborting...");
}
return [sha];
}
async mapSourceRepo(pr: PullRequest): Promise<GitRepository> {

View File

@@ -25,6 +25,7 @@ export default class GitLabMapper implements GitResponseMapper<MergeRequestSchem
}
async mapPullRequest(mr: MergeRequestSchema, commits?: string[]): Promise<GitPullRequest> {
return {
number: mr.iid,
author: mr.author.username,
@@ -47,9 +48,14 @@ export default class GitLabMapper implements GitResponseMapper<MergeRequestSchem
}
private getSha(mr: MergeRequestSchema) {
// if mr is merged, use merge_commit_sha otherwise use sha
// if mr is merged, use merge_commit_sha (or squash_commit_sha) otherwise use sha
// what is the difference between sha and diff_refs.head_sha?
return this.isMerged(mr) ? [mr.squash_commit_sha ? mr.squash_commit_sha : mr.merge_commit_sha as string] : [mr.sha];
const sha = this.isMerged(mr) ? (mr.squash_commit_sha ? mr.squash_commit_sha : mr.merge_commit_sha as string) : mr.sha;
if (!sha) {
throw new Error("Trying to backport a single squashed/merged commit that does not exist! Aborting...");
}
return [sha];
}
async mapSourceRepo(mr: MergeRequestSchema): Promise<GitRepository> {

View File

@@ -5,7 +5,7 @@ import PullRequestConfigsParser from "@bp/service/configs/pullrequest/pr-configs
import GitCLIService from "@bp/service/git/git-cli";
import GitClient from "@bp/service/git/git-client";
import GitClientFactory from "@bp/service/git/git-client-factory";
import { BackportPullRequest, GitClientType, GitPullRequest } from "@bp/service/git/git.types";
import { BackportPullRequest, GitClientType } from "@bp/service/git/git.types";
import LoggerService from "@bp/service/logger/logger-service";
import LoggerServiceFactory from "@bp/service/logger/logger-service-factory";
import { inferGitClient, inferGitApiUrl, getGitTokenFromEnv } from "@bp/service/git/git-util";
@@ -13,8 +13,8 @@ import { injectError, injectTargetBranch } from "./runner-util";
interface Git {
gitClientType: GitClientType;
gitClientApi: GitClient;
gitCli: GitCLIService;
gitClientApi: Pick<GitClient, ("createPullRequest" | "createPullRequestComment")>;
gitCli: Pick<GitCLIService, ("clone" | "createLocalBranch" | "fetch" | "cherryPick" | "push")>;
}
/**
@@ -84,23 +84,18 @@ export default class Runner {
const failures: string[] = [];
// we need sequential backporting as they will operate on the same folder
// avoid cloning the same repo multiple times
for(const pr of backportPRs) {
for (const pr of backportPRs) {
this.logger.setContext(pr.base);
try {
await this.executeBackport(configs, pr, {
gitClientType: gitClientType,
gitClientApi: gitApi,
gitCli: git,
});
} catch(error) {
this.logger.error(`Something went wrong backporting to ${pr.base}: ${error}`);
if (!configs.dryRun && configs.errorNotification.enabled && configs.errorNotification.message.length > 0) {
// notify the failure as comment in the original pull request
let comment = injectError(configs.errorNotification.message, error as string);
comment = injectTargetBranch(comment, pr.base);
await gitApi.createPullRequestComment(configs.originalPullRequest.url, comment);
}
} catch (error) {
failures.push(error as string);
}
this.logger.clearContext();
}
if (failures.length > 0) {
@@ -130,45 +125,147 @@ export default class Runner {
}
async executeBackport(configs: Configs, backportPR: BackportPullRequest, git: Git): Promise<void> {
this.logger.setContext(backportPR.base);
const originalPR: GitPullRequest = configs.originalPullRequest;
// 4. clone the repository
this.logger.debug("Cloning repo..");
await git.gitCli.clone(configs.originalPullRequest.targetRepo.cloneUrl, configs.folder, backportPR.base);
// 5. create new branch from target one and checkout
this.logger.debug("Creating local branch..");
await git.gitCli.createLocalBranch(configs.folder, backportPR.head);
// 6. fetch pull request remote if source owner != target owner or pull request still open
if (configs.originalPullRequest.sourceRepo.owner !== configs.originalPullRequest.targetRepo.owner ||
configs.originalPullRequest.state === "open") {
this.logger.debug("Fetching pull request remote..");
const prefix = git.gitClientType === GitClientType.GITLAB ? "merge-requests" : "pull" ; // default is for gitlab
await git.gitCli.fetch(configs.folder, `${prefix}/${configs.originalPullRequest.number}/head:pr/${configs.originalPullRequest.number}`);
let i = 0;
for (const step of backportSteps(this.logger, configs, backportPR, git)) {
try {
await step();
} catch (error) {
this.logger.error(`Something went wrong backporting to ${backportPR.base}: ${error}`);
if (!configs.dryRun && configs.errorNotification.enabled && configs.errorNotification.message.length > 0) {
// notify the failure as comment in the original pull request
let comment = injectError(configs.errorNotification.message, error as string);
comment = injectTargetBranch(comment, backportPR.base);
try {
let script = "\n\nReconstruction of the attempted steps (beware that escaping may be missing):\n```sh\n";
script += await backportScript(configs, backportPR, git, i);
script += "```";
comment += script;
} catch (scriptError) {
this.logger.error(`Something went wrong reconstructing the script: ${scriptError}`);
}
await git.gitClientApi.createPullRequestComment(configs.originalPullRequest.url, comment);
}
throw error;
}
i++;
}
// 7. apply all changes to the new branch
this.logger.debug("Cherry picking commits..");
for (const sha of originalPR.commits) {
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
}
if (!configs.dryRun) {
// 8. push the new branch to origin
await git.gitCli.push(configs.folder, backportPR.head);
// 9. create pull request new branch -> target branch (using octokit)
const prUrl = await git.gitClientApi.createPullRequest(backportPR);
this.logger.info(`Pull request created: ${prUrl}`);
} else {
this.logger.warn("Pull request creation and remote push skipped");
this.logger.info(`${JSON.stringify(backportPR, null, 2)}`);
}
this.logger.clearContext();
}
}
function* backportSteps(logger: Pick<LoggerService, "debug" | "info" | "warn">, configs: Configs, backportPR: BackportPullRequest, git: Git): Generator<() => Promise<void>, void, unknown> {
// every failible operation should be in one dedicated closure
// 4. clone the repository
yield async () => {
logger.debug("Cloning repo..");
await git.gitCli.clone(configs.originalPullRequest.targetRepo.cloneUrl, configs.folder, backportPR.base);
};
// 5. create new branch from target one and checkout
yield async () => {
logger.debug("Creating local branch..");
await git.gitCli.createLocalBranch(configs.folder, backportPR.head);
};
// 6. fetch pull request remote if source owner != target owner or pull request still open
if (configs.originalPullRequest.sourceRepo.owner !== configs.originalPullRequest.targetRepo.owner ||
configs.originalPullRequest.state === "open") {
yield async () => {
logger.debug("Fetching pull request remote..");
const prefix = git.gitClientType === GitClientType.GITLAB ? "merge-requests" : "pull"; // default is for gitlab
await git.gitCli.fetch(configs.folder, `${prefix}/${configs.originalPullRequest.number}/head:pr/${configs.originalPullRequest.number}`);
};
}
// 7. apply all changes to the new branch
yield async () => {
logger.debug("Cherry picking commits..");
};
for (const sha of configs.originalPullRequest.commits) {
yield async () => {
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
};
}
if (!configs.dryRun) {
// 8. push the new branch to origin
yield async () => {
await git.gitCli.push(configs.folder, backportPR.head);
};
// 9. create pull request new branch -> target branch (using octokit)
yield async () => {
const prUrl = await git.gitClientApi.createPullRequest(backportPR);
logger.info(`Pull request created: ${prUrl}`);
};
} else {
yield async () => {
logger.warn("Pull request creation and remote push skipped");
logger.info(`${JSON.stringify(backportPR, null, 2)}`);
};
}
}
// backportScript reconstruct the git commands that were run to attempt the backport.
async function backportScript(configs: Configs, backportPR: BackportPullRequest, git: Git, failed: number): Promise<string> {
let s = "";
const fakeLogger = {
debug: function(_message: string): void { /*discard*/ },
info: function(_message: string): void { /*discard*/ },
warn: function(_message: string): void { /*discard*/ },
};
const fakeGitCli: Git["gitCli"] = {
async clone(_from: string, _to: string, _branch: string): Promise<void> {
/* consider that the user already has the repo cloned (or knows how to clone) */
s += `git fetch origin ${backportPR.base}`;
},
async createLocalBranch(_cwd: string, newBranch: string): Promise<void> {
s += `git switch -c ${newBranch} origin/${backportPR.base}`;
},
async fetch(_cwd: string, branch: string, remote = "origin"): Promise<void> {
s += `git fetch ${remote} ${branch}`;
},
async cherryPick(_cwd: string, sha: string, strategy = "recursive", strategyOption = "theirs", cherryPickOptions: string | undefined): Promise<void> {
s += `git cherry-pick -m 1 --strategy=${strategy} --strategy-option=${strategyOption} `;
if (cherryPickOptions !== undefined) {
s += cherryPickOptions + " ";
}
s += sha;
},
async push(_cwd: string, branch: string, remote = "origin", force = false): Promise<void> {
s += `git push ${remote} ${branch}`;
if (force) {
s += " --force";
}
}
};
let i = 0;
let steps = "";
for (const step of backportSteps(fakeLogger, configs, backportPR, {
gitClientType: git.gitClientType,
gitClientApi: {
async createPullRequest(_backport: BackportPullRequest): Promise<string> {
s += `# ${git.gitClientType}.createPullRequest`;
return "";
},
async createPullRequestComment(_prUrl: string, _comment: string): Promise<string | undefined> {
s += `# ${git.gitClientType}.createPullRequestComment`;
return "";
}
},
gitCli: fakeGitCli,
})) {
if (i == failed) {
s += "# the step below failed\n";
}
await step();
if (s.length > 0 || i == failed) {
steps += s + "\n";
s = "";
}
i++;
}
return steps;
}

View File

@@ -505,7 +505,7 @@ describe("cli args parser", () => {
"https://localhost/whatever/pulls/1"
]);
expect(() => parser.parse()).toThrowError("Missing option: target branch(es) or target regular expression must be provided");
expect(() => parser.parse()).toThrow("Missing option: target branch(es) or target regular expression must be provided");
});
test("invalid execution with missing mandatory target branch", () => {
@@ -514,7 +514,7 @@ describe("cli args parser", () => {
"https://localhost/whatever/pulls/1"
]);
expect(() => parser.parse()).toThrowError("Missing option: target branch(es) or target regular expression must be provided");
expect(() => parser.parse()).toThrow("Missing option: target branch(es) or target regular expression must be provided");
});
test("invalid execution with missing mandatory pull request", () => {
@@ -523,7 +523,7 @@ describe("cli args parser", () => {
"target",
]);
expect(() => parser.parse()).toThrowError("Missing option: pull request must be provided");
expect(() => parser.parse()).toThrow("Missing option: pull request must be provided");
});
test("enable error notification flag", () => {

View File

@@ -301,7 +301,7 @@ describe("gha args parser", () => {
"pull-request": "https://localhost/whatever/pulls/1"
});
expect(() => parser.parse()).toThrowError("Missing option: target branch(es) or target regular expression must be provided");
expect(() => parser.parse()).toThrow("Missing option: target branch(es) or target regular expression must be provided");
});
test("invalid execution with missing mandatory target branch", () => {
@@ -309,7 +309,7 @@ describe("gha args parser", () => {
"pull-request": "https://localhost/whatever/pulls/1"
});
expect(() => parser.parse()).toThrowError("Missing option: target branch(es) or target regular expression must be provided");
expect(() => parser.parse()).toThrow("Missing option: target branch(es) or target regular expression must be provided");
});
test("invalid execution with missin mandatory pull request", () => {
@@ -317,7 +317,7 @@ describe("gha args parser", () => {
"target-branch": "target,old",
});
expect(() => parser.parse()).toThrowError("Missing option: pull request must be provided");
expect(() => parser.parse()).toThrow("Missing option: pull request must be provided");
});
test("enable error notification flag", () => {

View File

@@ -56,10 +56,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");
@@ -128,10 +128,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");
@@ -201,10 +201,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");
@@ -274,10 +274,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");
@@ -364,10 +364,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 8632, false);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 8632, false);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -435,10 +435,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 8632, false);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 8632, false);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({

View File

@@ -88,10 +88,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -185,10 +185,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 4444, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 4444, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
expect(configs.dryRun).toEqual(true);
expect(configs.auth).toEqual("whatever");
@@ -260,10 +260,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -333,10 +333,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");
@@ -374,10 +374,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -446,10 +446,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -520,10 +520,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -583,10 +583,10 @@ describe("github pull request config parser", () => {
const args: Args = argsParser.parse();
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, true);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, true);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -645,10 +645,10 @@ describe("github pull request config parser", () => {
const args: Args = argsParser.parse();
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, true);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, true);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -715,10 +715,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 8632, false);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 8632, false);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -793,10 +793,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -890,10 +890,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -955,10 +955,10 @@ describe("github pull request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.getPullRequest).toHaveBeenCalledWith("owner", "reponame", 2368, undefined);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.errorNotification).toEqual({
"enabled": true,

View File

@@ -56,10 +56,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");
@@ -129,10 +129,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");
@@ -203,10 +203,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");
@@ -277,10 +277,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.auth).toEqual("");

View File

@@ -93,10 +93,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -168,10 +168,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(true);
expect(configs.auth).toEqual("whatever");
@@ -198,10 +198,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 2, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 2, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(true);
expect(configs.auth).toEqual("whatever");
@@ -275,10 +275,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -347,10 +347,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -419,10 +419,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -493,10 +493,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -554,10 +554,10 @@ describe("gitlab merge request config parser", () => {
const args: Args = argsParser.parse();
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -615,10 +615,10 @@ describe("gitlab merge request config parser", () => {
const args: Args = argsParser.parse();
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -684,10 +684,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 2, false);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), ["e4dd336a4a20f394df6665994df382fb1d193a11", "974519f65c9e0ed65277cd71026657a09fca05e7"]);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 2, false);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), ["e4dd336a4a20f394df6665994df382fb1d193a11", "974519f65c9e0ed65277cd71026657a09fca05e7"]);
expect(configs.dryRun).toEqual(true);
expect(configs.auth).toEqual("whatever");
@@ -759,10 +759,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -834,10 +834,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, true);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.dryRun).toEqual(false);
expect(configs.git).toEqual({
@@ -898,10 +898,10 @@ describe("gitlab merge request config parser", () => {
const configs: Configs = await configParser.parseAndValidate(args);
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, undefined);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.getPullRequest).toHaveBeenCalledWith("superuser", "backporting-example", 1, undefined);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabMapper.prototype.mapPullRequest).toHaveBeenCalledWith(expect.anything(), []);
expect(configs.errorNotification).toEqual({
"enabled": true,

View File

@@ -88,11 +88,11 @@ describe("git cli service", () => {
});
test("fetch", async () => {
await expect(git.fetch(cwd, currentBranch)).resolves.not.toThrowError();
await expect(git.fetch(cwd, currentBranch)).resolves.not.toThrow();
});
test("local branch", async () => {
await expect(git.createLocalBranch(cwd, "new-local-branch")).resolves.not.toThrowError();
await expect(git.createLocalBranch(cwd, "new-local-branch")).resolves.not.toThrow();
// use rev-parse to double check the current branch is the new one
const output = spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd }).stdout.toString().trim();

View File

@@ -44,7 +44,7 @@ describe("check git utilities", () => {
});
test("not recognized git client type", ()=> {
expect(() => inferGitClient("https://not.recognized/superuser/backporting-example/-/merge_requests/4")).toThrowError("Remote git service not recognized from pr url: https://not.recognized/superuser/backporting-example/-/merge_requests/4");
expect(() => inferGitClient("https://not.recognized/superuser/backporting-example/-/merge_requests/4")).toThrow("Remote git service not recognized from pr url: https://not.recognized/superuser/backporting-example/-/merge_requests/4");
});
test("check infer github client using github api", ()=> {

View File

@@ -49,10 +49,10 @@ describe("github service", () => {
expect(res.commits).toEqual(["ebb1eca696c42fd067658bd9b5267709f78ef38e"]);
// check axios invocation
expect(axiosInstanceSpy.get).toBeCalledTimes(3); // merge request and 2 repos
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/1");
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/76316");
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/76316");
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(3); // merge request and 2 repos
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/1");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/76316");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/76316");
});
test("get open pull request", async () => {
@@ -72,10 +72,10 @@ describe("github service", () => {
expect(res.commits).toEqual(["9e15674ebd48e05c6e428a1fa31dbb60a778d644"]);
// check axios invocation
expect(axiosInstanceSpy.get).toBeCalledTimes(3); // merge request and 2 repos
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/2");
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/76316");
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/76316");
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(3); // merge request and 2 repos
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/2");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/76316");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/76316");
});
test("create backport pull request without reviewers and assignees", async () => {
@@ -96,8 +96,8 @@ describe("github service", () => {
expect(url).toStrictEqual("https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/" + NEW_GITLAB_MR_ID);
// check axios invocation
expect(axiosInstanceSpy.post).toBeCalledTimes(1);
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
expect(axiosInstanceSpy.post).toHaveBeenCalledTimes(1);
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
source_branch: "bp-branch",
target_branch: "old/branch",
title: "Backport Title",
@@ -105,8 +105,8 @@ describe("github service", () => {
reviewer_ids: [],
assignee_ids: [],
}));
expect(axiosInstanceSpy.get).toBeCalledTimes(0); // no reviewers nor assignees
expect(axiosInstanceSpy.put).toBeCalledTimes(0); // no reviewers nor assignees
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(0); // no reviewers nor assignees
expect(axiosInstanceSpy.put).toHaveBeenCalledTimes(0); // no reviewers nor assignees
});
test("create backport pull request with reviewers", async () => {
@@ -127,8 +127,8 @@ describe("github service", () => {
expect(url).toStrictEqual("https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/" + NEW_GITLAB_MR_ID);
// check axios invocation
expect(axiosInstanceSpy.post).toBeCalledTimes(1);
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
expect(axiosInstanceSpy.post).toHaveBeenCalledTimes(1);
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
source_branch: "bp-branch",
target_branch: "old/branch",
title: "Backport Title",
@@ -136,11 +136,11 @@ describe("github service", () => {
reviewer_ids: [],
assignee_ids: [],
}));
expect(axiosInstanceSpy.get).toBeCalledTimes(2); // just reviewers, one invalid
expect(axiosInstanceSpy.get).toBeCalledWith("/users?username=superuser");
expect(axiosInstanceSpy.get).toBeCalledWith("/users?username=invalid");
expect(axiosInstanceSpy.put).toBeCalledTimes(1); // just reviewers
expect(axiosInstanceSpy.put).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + NEW_GITLAB_MR_ID, {
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(2); // just reviewers, one invalid
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/users?username=superuser");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/users?username=invalid");
expect(axiosInstanceSpy.put).toHaveBeenCalledTimes(1); // just reviewers
expect(axiosInstanceSpy.put).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + NEW_GITLAB_MR_ID, {
reviewer_ids: [14041],
});
});
@@ -163,8 +163,8 @@ describe("github service", () => {
expect(url).toStrictEqual("https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/" + NEW_GITLAB_MR_ID);
// check axios invocation
expect(axiosInstanceSpy.post).toBeCalledTimes(1);
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
expect(axiosInstanceSpy.post).toHaveBeenCalledTimes(1);
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
source_branch: "bp-branch",
target_branch: "old/branch",
title: "Backport Title",
@@ -172,11 +172,11 @@ describe("github service", () => {
reviewer_ids: [],
assignee_ids: [],
}));
expect(axiosInstanceSpy.get).toBeCalledTimes(2); // just assignees, one invalid
expect(axiosInstanceSpy.get).toBeCalledWith("/users?username=superuser");
expect(axiosInstanceSpy.get).toBeCalledWith("/users?username=invalid");
expect(axiosInstanceSpy.put).toBeCalledTimes(1); // just assignees
expect(axiosInstanceSpy.put).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + NEW_GITLAB_MR_ID, {
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(2); // just assignees, one invalid
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/users?username=superuser");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/users?username=invalid");
expect(axiosInstanceSpy.put).toHaveBeenCalledTimes(1); // just assignees
expect(axiosInstanceSpy.put).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + NEW_GITLAB_MR_ID, {
assignee_ids: [14041],
});
});
@@ -199,8 +199,8 @@ describe("github service", () => {
expect(url).toStrictEqual("https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/" + SECOND_NEW_GITLAB_MR_ID);
// check axios invocation
expect(axiosInstanceSpy.post).toBeCalledTimes(1);
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
expect(axiosInstanceSpy.post).toHaveBeenCalledTimes(1);
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
source_branch: "bp-branch-2",
target_branch: "old/branch",
title: "Backport Title",
@@ -208,11 +208,11 @@ describe("github service", () => {
reviewer_ids: [],
assignee_ids: [],
}));
expect(axiosInstanceSpy.get).toBeCalledTimes(2); // just reviewers, one invalid
expect(axiosInstanceSpy.get).toBeCalledWith("/users?username=superuser");
expect(axiosInstanceSpy.get).toBeCalledWith("/users?username=invalid");
expect(axiosInstanceSpy.put).toBeCalledTimes(1); // just reviewers
expect(axiosInstanceSpy.put).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID, {
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(2); // just reviewers, one invalid
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/users?username=superuser");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/users?username=invalid");
expect(axiosInstanceSpy.put).toHaveBeenCalledTimes(1); // just reviewers
expect(axiosInstanceSpy.put).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID, {
reviewer_ids: [14041],
});
});
@@ -235,8 +235,8 @@ describe("github service", () => {
expect(url).toStrictEqual("https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/" + SECOND_NEW_GITLAB_MR_ID);
// check axios invocation
expect(axiosInstanceSpy.post).toBeCalledTimes(1);
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
expect(axiosInstanceSpy.post).toHaveBeenCalledTimes(1);
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
source_branch: "bp-branch-2",
target_branch: "old/branch",
title: "Backport Title",
@@ -244,11 +244,11 @@ describe("github service", () => {
reviewer_ids: [],
assignee_ids: [],
}));
expect(axiosInstanceSpy.get).toBeCalledTimes(2); // just assignees, one invalid
expect(axiosInstanceSpy.get).toBeCalledWith("/users?username=superuser");
expect(axiosInstanceSpy.get).toBeCalledWith("/users?username=invalid");
expect(axiosInstanceSpy.put).toBeCalledTimes(1); // just assignees
expect(axiosInstanceSpy.put).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID, {
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(2); // just assignees, one invalid
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/users?username=superuser");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/users?username=invalid");
expect(axiosInstanceSpy.put).toHaveBeenCalledTimes(1); // just assignees
expect(axiosInstanceSpy.put).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID, {
assignee_ids: [14041],
});
});
@@ -271,8 +271,8 @@ describe("github service", () => {
expect(url).toStrictEqual("https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/" + SECOND_NEW_GITLAB_MR_ID);
// check axios invocation
expect(axiosInstanceSpy.post).toBeCalledTimes(1);
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
expect(axiosInstanceSpy.post).toHaveBeenCalledTimes(1);
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
source_branch: "bp-branch-2",
target_branch: "old/branch",
title: "Backport Title",
@@ -280,9 +280,9 @@ describe("github service", () => {
reviewer_ids: [],
assignee_ids: [],
}));
expect(axiosInstanceSpy.get).toBeCalledTimes(0);
expect(axiosInstanceSpy.put).toBeCalledTimes(1); // just labels
expect(axiosInstanceSpy.put).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID, {
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(0);
expect(axiosInstanceSpy.put).toHaveBeenCalledTimes(1); // just labels
expect(axiosInstanceSpy.put).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID, {
labels: "label1,label2",
});
});
@@ -305,8 +305,8 @@ describe("github service", () => {
expect(url).toStrictEqual("https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/" + SECOND_NEW_GITLAB_MR_ID);
// check axios invocation
expect(axiosInstanceSpy.post).toBeCalledTimes(3); // also comments
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
expect(axiosInstanceSpy.post).toHaveBeenCalledTimes(3); // also comments
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests", expect.objectContaining({
source_branch: "bp-branch-2",
target_branch: "old/branch",
title: "Backport Title",
@@ -314,12 +314,12 @@ describe("github service", () => {
reviewer_ids: [],
assignee_ids: [],
}));
expect(axiosInstanceSpy.get).toBeCalledTimes(0);
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(0);
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID + "/notes", {
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID + "/notes", {
body: "this is first comment",
});
expect(axiosInstanceSpy.post).toBeCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID + "/notes", {
expect(axiosInstanceSpy.post).toHaveBeenCalledWith("/projects/superuser%2Fbackporting-example/merge_requests/" + SECOND_NEW_GITLAB_MR_ID + "/notes", {
body: "this is second comment",
});
});
@@ -343,9 +343,9 @@ describe("github service", () => {
expect(res.commits).toEqual(["ebb1eca696c42fd067658bd9b5267709f78ef38e"]);
// check axios invocation
expect(axiosInstanceSpy.get).toBeCalledTimes(3); // merge request and 2 repos
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/mysuperorg%2F6%2Fmysuperproduct%2Fmysuperunit%2Fbackporting-example/merge_requests/4");
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/1645");
expect(axiosInstanceSpy.get).toBeCalledWith("/projects/1645");
expect(axiosInstanceSpy.get).toHaveBeenCalledTimes(3); // merge request and 2 repos
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/mysuperorg%2F6%2Fmysuperproduct%2Fmysuperunit%2Fbackporting-example/merge_requests/4");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/1645");
expect(axiosInstanceSpy.get).toHaveBeenCalledWith("/projects/1645");
});
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -89,24 +89,24 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(0);
expect(GitLabClient.prototype.createPullRequestComment).toBeCalledTimes(0);
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(0);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(0);
expect(GitLabClient.prototype.createPullRequestComment).toHaveBeenCalledTimes(0);
});
test("dry run with relative folder", async () => {
@@ -124,26 +124,26 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/folder";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0);
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0);
expect(GitCLIService.prototype.addRemote).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.addRemote).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(0);
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(0);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(0);
});
test("without dry run", async () => {
@@ -158,26 +158,26 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-9e15674");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-9e15674",
@@ -201,7 +201,7 @@ describe("cli runner", () => {
]);
await expect(() => runner.execute()).rejects.toThrow("Provided pull request is closed and not merged");
expect(GitLabClient.prototype.createPullRequestComment).toBeCalledTimes(0);
expect(GitLabClient.prototype.createPullRequestComment).toHaveBeenCalledTimes(0);
});
test("merged pull request", async () => {
@@ -216,27 +216,27 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
// 0 occurrences as the mr is already merged and the owner is the same for
// both source and target repositories
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-ebb1eca",
@@ -249,7 +249,7 @@ describe("cli runner", () => {
comments: [],
}
);
expect(GitLabClient.prototype.createPullRequestComment).toBeCalledTimes(0);
expect(GitLabClient.prototype.createPullRequestComment).toHaveBeenCalledTimes(0);
});
@@ -277,26 +277,26 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp_branch_name",
@@ -334,26 +334,26 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp_branch_name",
@@ -383,27 +383,27 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
// 0 occurrences as the mr is already merged and the owner is the same for
// both source and target repositories
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-ebb1eca",
@@ -432,27 +432,27 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
// 0 occurrences as the mr is already merged and the owner is the same for
// both source and target repositories
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-ebb1eca",
@@ -477,27 +477,27 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, "my-token", "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, "my-token", "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "prod");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "prod");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-prod-ebb1eca");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-prod-ebb1eca");
// 0 occurrences as the mr is already merged and the owner is the same for
// both source and target repositories
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-prod-ebb1eca");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-prod-ebb1eca");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-prod-ebb1eca",
@@ -525,23 +525,23 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-e4dd336");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-e4dd336",
@@ -569,27 +569,27 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336-974519f");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-e4dd336-974519f");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toHaveBeenNthCalledWith(1, cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenNthCalledWith(2, cwd, "974519f65c9e0ed65277cd71026657a09fca05e7", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336-974519f");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-e4dd336-974519f");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-e4dd336-974519f",
@@ -617,23 +617,23 @@ describe("cli runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-e4dd336");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-e4dd336",
@@ -660,8 +660,8 @@ describe("cli runner", () => {
await runner.execute();
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, "mygitlabtoken", "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, "mygitlabtoken", "https://my.gitlab.host.com/api/v4");
// Not interested in all subsequent calls, already tested in other test cases
});
@@ -679,8 +679,8 @@ describe("cli runner", () => {
await runner.execute();
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, "mytoken", "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, "mytoken", "https://my.gitlab.host.com/api/v4");
// Not interested in all subsequent calls, already tested in other test cases
});
@@ -697,9 +697,20 @@ describe("cli runner", () => {
await runner.execute();
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
// Not interested in all subsequent calls, already tested in other test cases
});
test("throw error if missing squash commit", async () => {
addProcessArgs([
"-tb",
"target",
"-pr",
"https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/6"
]);
await expect(() => runner.execute()).rejects.toThrow("Trying to backport a single squashed/merged commit that does not exist! Aborting...");
});
});

View File

@@ -71,24 +71,24 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(0);
expect(GitHubClient.prototype.createPullRequestComment).toBeCalledTimes(0);
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(0);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(0);
expect(GitHubClient.prototype.createPullRequestComment).toHaveBeenCalledTimes(0);
});
test("without dry run", async () => {
@@ -101,26 +101,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-28f63db",
@@ -133,7 +133,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("closed and not merged pull request", async () => {
@@ -155,26 +155,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-9174896");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-9174896");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/4444/head:pr/4444");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/4444/head:pr/4444");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "91748965051fae1330ad58d15cf694e103267c87", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "91748965051fae1330ad58d15cf694e103267c87", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9174896");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-9174896");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-9174896",
@@ -187,7 +187,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("override backporting pr data", async () => {
@@ -206,26 +206,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp_branch_name",
@@ -238,7 +238,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("set empty reviewers", async () => {
@@ -258,26 +258,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp_branch_name",
@@ -290,7 +290,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("set custom labels with inheritance", async () => {
@@ -305,26 +305,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-28f63db",
@@ -337,7 +337,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("set custom labels without inheritance", async () => {
@@ -352,26 +352,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-28f63db",
@@ -384,7 +384,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("using config file with overrides", async () => {
@@ -396,26 +396,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, "my-auth-token", "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, "my-auth-token", "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp_branch_name",
@@ -428,7 +428,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
// to check: https://github.com/kiegroup/git-backporting/issues/52
@@ -442,26 +442,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-28f63db",
@@ -474,7 +474,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("multiple commits pr", async () => {
@@ -488,26 +488,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-0404fb9-11da4e3");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-0404fb9-11da4e3");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenLastCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-0404fb9-11da4e3");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-0404fb9-11da4e3");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-0404fb9-11da4e3",
@@ -520,7 +520,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("using github api url and different strategy", async () => {
@@ -535,26 +535,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", "ort", "ours", undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", "ort", "ours", undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-28f63db",
@@ -567,7 +567,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("using github api url and additional cherry-pick options", async () => {
@@ -581,26 +581,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, "-x --allow-empty");
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, "-x --allow-empty");
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-28f63db",
@@ -613,7 +613,7 @@ describe("gha runner", () => {
comments: [],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("additional pr comments", async () => {
@@ -627,26 +627,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-28f63db");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-28f63db",
@@ -659,7 +659,7 @@ describe("gha runner", () => {
comments: ["first comment", "second comment"],
}
);
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(1);
});
test("with multiple target branches", async () => {
@@ -673,34 +673,34 @@ describe("gha runner", () => {
const cwd = "/tmp/folder";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(3);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "v1");
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "v2");
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "v3");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "v1");
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "v2");
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "v3");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(3);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-v1-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-v2-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-v3-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-v1-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-v2-28f63db");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-v3-28f63db");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(3);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(3);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(3);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-v1-28f63db");
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-v2-28f63db");
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-v3-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-v1-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-v2-28f63db");
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-v3-28f63db");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(3);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(3);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-v1-28f63db",
@@ -712,7 +712,7 @@ describe("gha runner", () => {
labels: [],
comments: [],
});
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-v2-28f63db",
@@ -724,7 +724,7 @@ describe("gha runner", () => {
labels: [],
comments: [],
});
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-v3-28f63db",
@@ -736,7 +736,7 @@ describe("gha runner", () => {
labels: [],
comments: [],
});
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(3);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(3);
});
test("with multiple target branches and single custom bp branch", async () => {
@@ -751,34 +751,34 @@ describe("gha runner", () => {
const cwd = "/tmp/folder";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(3);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "v1");
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "v2");
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "v3");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "v1");
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "v2");
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "v3");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(3);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "custom-v1");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "custom-v2");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "custom-v3");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "custom-v1");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "custom-v2");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "custom-v3");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(3);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(3);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(3);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "custom-v1");
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "custom-v2");
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "custom-v3");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(3);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "custom-v1");
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "custom-v2");
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "custom-v3");
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(3);
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledTimes(3);
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "custom-v1",
@@ -790,7 +790,7 @@ describe("gha runner", () => {
labels: [],
comments: [],
});
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "custom-v2",
@@ -802,7 +802,7 @@ describe("gha runner", () => {
labels: [],
comments: [],
});
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
expect(GitHubClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "owner",
repo: "reponame",
head: "custom-v3",
@@ -814,7 +814,7 @@ describe("gha runner", () => {
labels: [],
comments: [],
});
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(3);
expect(GitHubClient.prototype.createPullRequest).toHaveReturnedTimes(3);
});
test("explicitly set git client", async () => {
@@ -828,11 +828,11 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.CODEBERG, undefined, "https://api.github.com");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.CODEBERG, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://github.com/owner/reponame.git", cwd, "target");
});
});

View File

@@ -82,24 +82,24 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(0);
expect(GitLabClient.prototype.createPullRequestComment).toBeCalledTimes(0);
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(0);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(0);
expect(GitLabClient.prototype.createPullRequestComment).toHaveBeenCalledTimes(0);
});
test("without dry run", async () => {
@@ -112,26 +112,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9e15674");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-9e15674");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-9e15674",
@@ -165,25 +165,25 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-ebb1eca",
@@ -214,26 +214,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp_branch_name",
@@ -265,26 +265,26 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp_branch_name");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp_branch_name",
@@ -311,25 +311,25 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-ebb1eca",
@@ -355,25 +355,25 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-ebb1eca");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-ebb1eca",
@@ -397,27 +397,27 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, "my-token", "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, "my-token", "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "prod");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "prod");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-prod-ebb1eca");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-prod-ebb1eca");
// 0 occurrences as the mr is already merged and the owner is the same for
// both source and target repositories
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-prod-ebb1eca");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-prod-ebb1eca");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-prod-ebb1eca",
@@ -443,23 +443,23 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-e4dd336");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-e4dd336",
@@ -485,27 +485,27 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336-974519f");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-e4dd336-974519f");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.fetch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.fetch).toHaveBeenCalledWith(cwd, "merge-requests/2/head:pr/2");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "974519f65c9e0ed65277cd71026657a09fca05e7", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "974519f65c9e0ed65277cd71026657a09fca05e7", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336-974519f");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-e4dd336-974519f");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-e4dd336-974519f",
@@ -531,23 +531,23 @@ describe("gha runner", () => {
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitClientFactory.getOrCreate).toHaveBeenCalledTimes(1);
expect(GitClientFactory.getOrCreate).toHaveBeenCalledWith(GitClientType.GITLAB, undefined, "https://my.gitlab.host.com/api/v4");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.clone).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.clone).toHaveBeenCalledWith("https://my.gitlab.host.com/superuser/backporting-example.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toHaveBeenCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toHaveBeenCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336");
expect(GitCLIService.prototype.push).toHaveBeenCalledTimes(1);
expect(GitCLIService.prototype.push).toHaveBeenCalledWith(cwd, "bp-target-e4dd336");
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledTimes(1);
expect(GitLabClient.prototype.createPullRequest).toHaveBeenCalledWith({
owner: "superuser",
repo: "backporting-example",
head: "bp-target-e4dd336",

View File

@@ -1,7 +1,7 @@
import LoggerServiceFactory from "@bp/service/logger/logger-service-factory";
import { Moctokit } from "@kie/mock-github";
import { TARGET_OWNER, REPO, MERGED_PR_FIXTURE, OPEN_PR_FIXTURE, NOT_MERGED_PR_FIXTURE, NOT_FOUND_PR_NUMBER, MULT_COMMITS_PR_FIXTURE, MULT_COMMITS_PR_COMMITS, NEW_PR_URL, NEW_PR_NUMBER, GITHUB_GET_COMMIT } from "./github-data";
import { CLOSED_NOT_MERGED_MR, MERGED_SQUASHED_MR, NESTED_NAMESPACE_MR, OPEN_MR, OPEN_PR_COMMITS, PROJECT_EXAMPLE, NESTED_PROJECT_EXAMPLE, SUPERUSER, MERGED_SQUASHED_MR_COMMITS, MERGED_NOT_SQUASHED_MR, MERGED_NOT_SQUASHED_MR_COMMITS } from "./gitlab-data";
import { CLOSED_NOT_MERGED_MR, MERGED_SQUASHED_MR, NESTED_NAMESPACE_MR, OPEN_MR, OPEN_PR_COMMITS, PROJECT_EXAMPLE, NESTED_PROJECT_EXAMPLE, SUPERUSER, MERGED_SQUASHED_MR_COMMITS, MERGED_NOT_SQUASHED_MR, MERGED_NOT_SQUASHED_MR_COMMITS, UNDEFINED_COMMITS_MR } from "./gitlab-data";
import { CB_TARGET_OWNER, CB_REPO, CB_MERGED_PR_FIXTURE, CB_OPEN_PR_FIXTURE, CB_NOT_MERGED_PR_FIXTURE, CB_NOT_FOUND_PR_NUMBER, CB_MULT_COMMITS_PR_FIXTURE, CB_MULT_COMMITS_PR_COMMITS, CB_NEW_PR_URL, CB_NEW_PR_NUMBER, CODEBERG_GET_COMMIT } from "./codeberg-data";
// high number, for each test we are not expecting
@@ -27,6 +27,8 @@ export const getAxiosMocked = (url: string) => {
data = NESTED_NAMESPACE_MR;
} else if (url.endsWith("merge_requests/5")) {
data = MERGED_NOT_SQUASHED_MR;
} else if (url.endsWith("merge_requests/6")) {
data = UNDEFINED_COMMITS_MR;
} else if (url.endsWith("projects/76316")) {
data = PROJECT_EXAMPLE;
} else if (url.endsWith("projects/1645")) {

View File

@@ -1055,4 +1055,139 @@ export const MERGED_NOT_SQUASHED_MR = {
"user":{
"can_merge":true
}
};
export const UNDEFINED_COMMITS_MR = {
"id":807106,
"iid":6,
"project_id":76316,
"title":"Update test.txt",
"description":"This is the body",
"state":"merged",
"created_at":"2023-06-28T14:32:40.943Z",
"updated_at":"2023-06-28T14:37:12.108Z",
"merged_by":{
"id":14041,
"username":"superuser",
"name":"Super User",
"state":"active",
"avatar_url":"https://my.gitlab.host.com/uploads/-/system/user/avatar/14041/avatar.png",
"web_url":"https://my.gitlab.host.com/superuser"
},
"merge_user":{
"id":14041,
"username":"superuser",
"name":"Super User",
"state":"active",
"avatar_url":"https://my.gitlab.host.com/uploads/-/system/user/avatar/14041/avatar.png",
"web_url":"https://my.gitlab.host.com/superuser"
},
"merged_at":"2023-06-28T14:37:11.667Z",
"closed_by":null,
"closed_at":null,
"target_branch":"main",
"source_branch":"feature",
"user_notes_count":0,
"upvotes":0,
"downvotes":0,
"author":{
"id":14041,
"username":"superuser",
"name":"Super User",
"state":"active",
"avatar_url":"https://my.gitlab.host.com/uploads/-/system/user/avatar/14041/avatar.png",
"web_url":"https://my.gitlab.host.com/superuser"
},
"assignees":[
{
"id":14041,
"username":"superuser",
"name":"Super User",
"state":"active",
"avatar_url":"https://my.gitlab.host.com/uploads/-/system/user/avatar/14041/avatar.png",
"web_url":"https://my.gitlab.host.com/superuser"
}
],
"assignee":{
"id":14041,
"username":"superuser",
"name":"Super User",
"state":"active",
"avatar_url":"https://my.gitlab.host.com/uploads/-/system/user/avatar/14041/avatar.png",
"web_url":"https://my.gitlab.host.com/superuser"
},
"reviewers":[
{
"id":1404188,
"username":"superuser1",
"name":"Super User",
"state":"active",
"avatar_url":"https://my.gitlab.host.com/uploads/-/system/user/avatar/14041/avatar.png",
"web_url":"https://my.gitlab.host.com/superuser"
},
{
"id":1404199,
"username":"superuser2",
"name":"Super User",
"state":"active",
"avatar_url":"https://my.gitlab.host.com/uploads/-/system/user/avatar/14041/avatar.png",
"web_url":"https://my.gitlab.host.com/superuser"
}
],
"source_project_id":76316,
"target_project_id":76316,
"labels":[
"backport-prod"
],
"draft":false,
"work_in_progress":false,
"milestone":null,
"merge_when_pipeline_succeeds":false,
"merge_status":"can_be_merged",
"detailed_merge_status":"not_open",
"sha":"9e15674ebd48e05c6e428a1fa31dbb60a778d644",
"merge_commit_sha":undefined,
"squash_commit_sha":undefined,
"discussion_locked":null,
"should_remove_source_branch":true,
"force_remove_source_branch":true,
"reference":"!2",
"references":{
"short":"!2",
"relative":"!2",
"full":"superuser/backporting-example!6"
},
"web_url":"https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/6",
"time_stats":{
"time_estimate":0,
"total_time_spent":0,
"human_time_estimate":null,
"human_total_time_spent":null
},
"squash":true,
"squash_on_merge":true,
"task_completion_status":{
"count":0,
"completed_count":0
},
"has_conflicts":false,
"blocking_discussions_resolved":true,
"approvals_before_merge":null,
"subscribed":true,
"changes_count":"1",
"latest_build_started_at":null,
"latest_build_finished_at":null,
"first_deployed_to_production_at":null,
"pipeline":null,
"head_pipeline":null,
"diff_refs":{
"base_sha":"2c553a0c4c133a51806badce5fa4842b7253cb3b",
"head_sha":"9e15674ebd48e05c6e428a1fa31dbb60a778d644",
"start_sha":"2c553a0c4c133a51806badce5fa4842b7253cb3b"
},
"merge_error":null,
"first_contribution":false,
"user":{
"can_merge":true
}
};