[ISSUE-18] backport still open pull requests

This commit is contained in:
Andrea Lamparelli 2023-01-04 14:50:28 +01:00
parent ec18e04885
commit bdbcd7e90c
14 changed files with 1203 additions and 41 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
npm run lint && npm run build && git add dist npm run lint && npm run build && git add dist && rm -rf build

32
dist/cli/index.js vendored
View file

@ -60,21 +60,33 @@ exports["default"] = CLIArgsParser;
/***/ }), /***/ }),
/***/ 5799: /***/ 5799:
/***/ ((__unused_webpack_module, exports) => { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const logger_service_factory_1 = __importDefault(__nccwpck_require__(8936));
/** /**
* Abstract configuration parser class in charge to parse * Abstract configuration parser class in charge to parse
* Args and produces a common Configs object * Args and produces a common Configs object
*/ */
class ConfigsParser { class ConfigsParser {
constructor() {
this.logger = logger_service_factory_1.default.getLogger();
}
async parseAndValidate(args) { async parseAndValidate(args) {
const configs = await this.parse(args); const configs = await this.parse(args);
// apply validation, throw errors if something is wrong // apply validation, throw errors if something is wrong
if (configs.originalPullRequest.state == "open" || !configs.originalPullRequest.merged) { // if pr is opened check if the there exists one single commit
throw new Error("Provided pull request is not merged!"); if (configs.originalPullRequest.state == "open") {
this.logger.warn("Trying to backport an open pull request!");
}
// if PR is closed and not merged log a warning
if (configs.originalPullRequest.state == "closed" && !configs.originalPullRequest.merged) {
throw new Error("Provided pull request is closed and not merged!");
} }
return Promise.resolve(configs); return Promise.resolve(configs);
} }
@ -136,6 +148,7 @@ class PullRequestConfigsParser extends configs_parser_1.default {
reviewers: [...new Set(reviewers)], reviewers: [...new Set(reviewers)],
targetRepo: originalPullRequest.targetRepo, targetRepo: originalPullRequest.targetRepo,
sourceRepo: originalPullRequest.targetRepo, sourceRepo: originalPullRequest.targetRepo,
nCommits: 0,
commits: [] // TODO needed? commits: [] // TODO needed?
}; };
} }
@ -237,6 +250,7 @@ class GitCLIService {
* @param remote [optional] the remote to fetch, by default origin * @param remote [optional] the remote to fetch, by default origin
*/ */
async fetch(cwd, branch, remote = "origin") { async fetch(cwd, branch, remote = "origin") {
this.logger.info(`Fetching ${remote} ${branch}.`);
await this.git(cwd).fetch(remote, branch, ["--quiet"]); await this.git(cwd).fetch(remote, branch, ["--quiet"]);
} }
/** /**
@ -339,6 +353,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
class GitHubMapper { class GitHubMapper {
mapPullRequest(pr) { mapPullRequest(pr) {
return { return {
number: pr.number,
author: pr.user.login, author: pr.user.login,
url: pr.url, url: pr.url,
htmlUrl: pr.html_url, htmlUrl: pr.html_url,
@ -358,7 +373,9 @@ class GitHubMapper {
project: pr.base.repo.full_name.split("/")[1], project: pr.base.repo.full_name.split("/")[1],
cloneUrl: pr.base.repo.clone_url cloneUrl: pr.base.repo.clone_url
}, },
commits: [pr.merge_commit_sha] nCommits: pr.commits,
// if pr is open use latest commit sha otherwise use merge_commit_sha
commits: pr.state === "open" ? [pr.head.sha] : [pr.merge_commit_sha]
}; };
} }
} }
@ -634,8 +651,11 @@ class Runner {
// 5. create new branch from target one and checkout // 5. create new branch from target one and checkout
const backportBranch = `bp-${configs.targetBranch}-${originalPR.commits.join("-")}`; const backportBranch = `bp-${configs.targetBranch}-${originalPR.commits.join("-")}`;
await git.createLocalBranch(configs.folder, backportBranch); await git.createLocalBranch(configs.folder, backportBranch);
// 6. add new remote if source != target and fetch source repo // 6. fetch pull request remote if source owner != target owner or pull request still open
// Skip this, we assume the PR has been already merged if (configs.originalPullRequest.sourceRepo.owner !== configs.originalPullRequest.targetRepo.owner ||
configs.originalPullRequest.state === "open") {
await git.fetch(configs.folder, `pull/${configs.originalPullRequest.number}/head:pr/${configs.originalPullRequest.number}`);
}
// 7. apply all changes to the new branch // 7. apply all changes to the new branch
for (const sha of originalPR.commits) { for (const sha of originalPR.commits) {
await git.cherryPick(configs.folder, sha); await git.cherryPick(configs.folder, sha);

32
dist/gha/index.js vendored
View file

@ -46,21 +46,33 @@ exports["default"] = GHAArgsParser;
/***/ }), /***/ }),
/***/ 5799: /***/ 5799:
/***/ ((__unused_webpack_module, exports) => { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const logger_service_factory_1 = __importDefault(__nccwpck_require__(8936));
/** /**
* Abstract configuration parser class in charge to parse * Abstract configuration parser class in charge to parse
* Args and produces a common Configs object * Args and produces a common Configs object
*/ */
class ConfigsParser { class ConfigsParser {
constructor() {
this.logger = logger_service_factory_1.default.getLogger();
}
async parseAndValidate(args) { async parseAndValidate(args) {
const configs = await this.parse(args); const configs = await this.parse(args);
// apply validation, throw errors if something is wrong // apply validation, throw errors if something is wrong
if (configs.originalPullRequest.state == "open" || !configs.originalPullRequest.merged) { // if pr is opened check if the there exists one single commit
throw new Error("Provided pull request is not merged!"); if (configs.originalPullRequest.state == "open") {
this.logger.warn("Trying to backport an open pull request!");
}
// if PR is closed and not merged log a warning
if (configs.originalPullRequest.state == "closed" && !configs.originalPullRequest.merged) {
throw new Error("Provided pull request is closed and not merged!");
} }
return Promise.resolve(configs); return Promise.resolve(configs);
} }
@ -122,6 +134,7 @@ class PullRequestConfigsParser extends configs_parser_1.default {
reviewers: [...new Set(reviewers)], reviewers: [...new Set(reviewers)],
targetRepo: originalPullRequest.targetRepo, targetRepo: originalPullRequest.targetRepo,
sourceRepo: originalPullRequest.targetRepo, sourceRepo: originalPullRequest.targetRepo,
nCommits: 0,
commits: [] // TODO needed? commits: [] // TODO needed?
}; };
} }
@ -223,6 +236,7 @@ class GitCLIService {
* @param remote [optional] the remote to fetch, by default origin * @param remote [optional] the remote to fetch, by default origin
*/ */
async fetch(cwd, branch, remote = "origin") { async fetch(cwd, branch, remote = "origin") {
this.logger.info(`Fetching ${remote} ${branch}.`);
await this.git(cwd).fetch(remote, branch, ["--quiet"]); await this.git(cwd).fetch(remote, branch, ["--quiet"]);
} }
/** /**
@ -325,6 +339,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
class GitHubMapper { class GitHubMapper {
mapPullRequest(pr) { mapPullRequest(pr) {
return { return {
number: pr.number,
author: pr.user.login, author: pr.user.login,
url: pr.url, url: pr.url,
htmlUrl: pr.html_url, htmlUrl: pr.html_url,
@ -344,7 +359,9 @@ class GitHubMapper {
project: pr.base.repo.full_name.split("/")[1], project: pr.base.repo.full_name.split("/")[1],
cloneUrl: pr.base.repo.clone_url cloneUrl: pr.base.repo.clone_url
}, },
commits: [pr.merge_commit_sha] nCommits: pr.commits,
// if pr is open use latest commit sha otherwise use merge_commit_sha
commits: pr.state === "open" ? [pr.head.sha] : [pr.merge_commit_sha]
}; };
} }
} }
@ -620,8 +637,11 @@ class Runner {
// 5. create new branch from target one and checkout // 5. create new branch from target one and checkout
const backportBranch = `bp-${configs.targetBranch}-${originalPR.commits.join("-")}`; const backportBranch = `bp-${configs.targetBranch}-${originalPR.commits.join("-")}`;
await git.createLocalBranch(configs.folder, backportBranch); await git.createLocalBranch(configs.folder, backportBranch);
// 6. add new remote if source != target and fetch source repo // 6. fetch pull request remote if source owner != target owner or pull request still open
// Skip this, we assume the PR has been already merged if (configs.originalPullRequest.sourceRepo.owner !== configs.originalPullRequest.targetRepo.owner ||
configs.originalPullRequest.state === "open") {
await git.fetch(configs.folder, `pull/${configs.originalPullRequest.number}/head:pr/${configs.originalPullRequest.number}`);
}
// 7. apply all changes to the new branch // 7. apply all changes to the new branch
for (const sha of originalPR.commits) { for (const sha of originalPR.commits) {
await git.cherryPick(configs.folder, sha); await git.cherryPick(configs.folder, sha);

View file

@ -1,5 +1,7 @@
import { Args } from "@bp/service/args/args.types"; import { Args } from "@bp/service/args/args.types";
import { Configs } from "@bp/service/configs/configs.types"; import { Configs } from "@bp/service/configs/configs.types";
import LoggerService from "../logger/logger-service";
import LoggerServiceFactory from "../logger/logger-service-factory";
/** /**
* Abstract configuration parser class in charge to parse * Abstract configuration parser class in charge to parse
@ -7,14 +9,27 @@ import { Configs } from "@bp/service/configs/configs.types";
*/ */
export default abstract class ConfigsParser { export default abstract class ConfigsParser {
private readonly logger: LoggerService;
constructor() {
this.logger = LoggerServiceFactory.getLogger();
}
abstract parse(args: Args): Promise<Configs>; abstract parse(args: Args): Promise<Configs>;
async parseAndValidate(args: Args): Promise<Configs> { async parseAndValidate(args: Args): Promise<Configs> {
const configs: Configs = await this.parse(args); const configs: Configs = await this.parse(args);
// apply validation, throw errors if something is wrong // apply validation, throw errors if something is wrong
if (configs.originalPullRequest.state == "open" || !configs.originalPullRequest.merged) {
throw new Error("Provided pull request is not merged!"); // if pr is opened check if the there exists one single commit
if (configs.originalPullRequest.state == "open") {
this.logger.warn("Trying to backport an open pull request!");
}
// if PR is closed and not merged log a warning
if (configs.originalPullRequest.state == "closed" && !configs.originalPullRequest.merged) {
throw new Error("Provided pull request is closed and not merged!");
} }
return Promise.resolve(configs); return Promise.resolve(configs);

View file

@ -54,6 +54,7 @@ export default class PullRequestConfigsParser extends ConfigsParser {
reviewers: [...new Set(reviewers)], reviewers: [...new Set(reviewers)],
targetRepo: originalPullRequest.targetRepo, targetRepo: originalPullRequest.targetRepo,
sourceRepo: originalPullRequest.targetRepo, sourceRepo: originalPullRequest.targetRepo,
nCommits: 0, // TODO: needed?
commits: [] // TODO needed? commits: [] // TODO needed?
}; };
} }

View file

@ -95,6 +95,7 @@ export default class GitCLIService {
* @param remote [optional] the remote to fetch, by default origin * @param remote [optional] the remote to fetch, by default origin
*/ */
async fetch(cwd: string, branch: string, remote = "origin"): Promise<void> { async fetch(cwd: string, branch: string, remote = "origin"): Promise<void> {
this.logger.info(`Fetching ${remote} ${branch}.`);
await this.git(cwd).fetch(remote, branch, ["--quiet"]); await this.git(cwd).fetch(remote, branch, ["--quiet"]);
} }

View file

@ -1,4 +1,5 @@
export interface GitPullRequest { export interface GitPullRequest {
number?: number,
author: string, author: string,
url?: string, url?: string,
htmlUrl?: string, htmlUrl?: string,
@ -10,7 +11,8 @@ export interface GitPullRequest {
reviewers: string[], reviewers: string[],
targetRepo: GitRepository, targetRepo: GitRepository,
sourceRepo: GitRepository, sourceRepo: GitRepository,
commits: string[] nCommits: number, // number of commits in the pr
commits: string[] // merge commit or last one
} }
export interface GitRepository { export interface GitRepository {

View file

@ -5,6 +5,7 @@ export default class GitHubMapper {
mapPullRequest(pr: PullRequest): GitPullRequest { mapPullRequest(pr: PullRequest): GitPullRequest {
return { return {
number: pr.number,
author: pr.user.login, author: pr.user.login,
url: pr.url, url: pr.url,
htmlUrl: pr.html_url, htmlUrl: pr.html_url,
@ -24,7 +25,9 @@ export default class GitHubMapper {
project: pr.base.repo.full_name.split("/")[1], project: pr.base.repo.full_name.split("/")[1],
cloneUrl: pr.base.repo.clone_url cloneUrl: pr.base.repo.clone_url
}, },
commits: [pr.merge_commit_sha as string] nCommits: pr.commits,
// if pr is open use latest commit sha otherwise use merge_commit_sha
commits: pr.state === "open" ? [pr.head.sha] : [pr.merge_commit_sha as string]
}; };
} }
} }

View file

@ -89,8 +89,11 @@ export default class Runner {
const backportBranch = `bp-${configs.targetBranch}-${originalPR.commits.join("-")}`; const backportBranch = `bp-${configs.targetBranch}-${originalPR.commits.join("-")}`;
await git.createLocalBranch(configs.folder, backportBranch); await git.createLocalBranch(configs.folder, backportBranch);
// 6. add new remote if source != target and fetch source repo // 6. fetch pull request remote if source owner != target owner or pull request still open
// Skip this, we assume the PR has been already merged if (configs.originalPullRequest.sourceRepo.owner !== configs.originalPullRequest.targetRepo.owner ||
configs.originalPullRequest.state === "open") {
await git.fetch(configs.folder, `pull/${configs.originalPullRequest.number}/head:pr/${configs.originalPullRequest.number}`);
}
// 7. apply all changes to the new branch // 7. apply all changes to the new branch
for (const sha of originalPR.commits) { for (const sha of originalPR.commits) {

View file

@ -4,11 +4,12 @@ import PullRequestConfigsParser from "@bp/service/configs/pullrequest/pr-configs
import GitServiceFactory from "@bp/service/git/git-service-factory"; import GitServiceFactory from "@bp/service/git/git-service-factory";
import { GitServiceType } from "@bp/service/git/git.types"; import { GitServiceType } from "@bp/service/git/git.types";
import { setupMoctokit } from "../../../support/moctokit/moctokit-support"; import { setupMoctokit } from "../../../support/moctokit/moctokit-support";
import { mergedPullRequestFixture, notMergedPullRequestFixture, repo, targetOwner } from "../../../support/moctokit/moctokit-data"; import { mergedPullRequestFixture, openPullRequestFixture, notMergedPullRequestFixture, repo, targetOwner } from "../../../support/moctokit/moctokit-data";
describe("pull request config parser", () => { describe("pull request config parser", () => {
const mergedPRUrl = `https://github.com/${targetOwner}/${repo}/pull/${mergedPullRequestFixture.number}`; const mergedPRUrl = `https://github.com/${targetOwner}/${repo}/pull/${mergedPullRequestFixture.number}`;
const openPRUrl = `https://github.com/${targetOwner}/${repo}/pull/${openPullRequestFixture.number}`;
const notMergedPRUrl = `https://github.com/${targetOwner}/${repo}/pull/${notMergedPullRequestFixture.number}`; const notMergedPRUrl = `https://github.com/${targetOwner}/${repo}/pull/${notMergedPullRequestFixture.number}`;
let parser: PullRequestConfigsParser; let parser: PullRequestConfigsParser;
@ -27,7 +28,7 @@ describe("pull request config parser", () => {
jest.clearAllMocks(); jest.clearAllMocks();
}); });
test("parse configs from pull request [default]", async () => { test("parse configs from pull request", async () => {
const args: Args = { const args: Args = {
dryRun: false, dryRun: false,
auth: "", auth: "",
@ -43,6 +44,7 @@ describe("pull request config parser", () => {
expect(configs.targetBranch).toEqual("prod"); expect(configs.targetBranch).toEqual("prod");
expect(configs.folder).toEqual(process.cwd() + "/bp"); expect(configs.folder).toEqual(process.cwd() + "/bp");
expect(configs.originalPullRequest).toEqual({ expect(configs.originalPullRequest).toEqual({
number: 2368,
author: "gh-user", author: "gh-user",
url: "https://api.github.com/repos/owner/reponame/pulls/2368", url: "https://api.github.com/repos/owner/reponame/pulls/2368",
htmlUrl: "https://github.com/owner/reponame/pull/2368", htmlUrl: "https://github.com/owner/reponame/pull/2368",
@ -62,6 +64,7 @@ describe("pull request config parser", () => {
project: "reponame", project: "reponame",
cloneUrl: "https://github.com/fork/reponame.git" cloneUrl: "https://github.com/fork/reponame.git"
}, },
nCommits: 2,
commits: ["28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"] commits: ["28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"]
}); });
expect(configs.backportPullRequest).toEqual({ expect(configs.backportPullRequest).toEqual({
@ -81,6 +84,7 @@ describe("pull request config parser", () => {
project: "reponame", project: "reponame",
cloneUrl: "https://github.com/owner/reponame.git" cloneUrl: "https://github.com/owner/reponame.git"
}, },
nCommits: 0,
commits: [] commits: []
}); });
}); });
@ -119,7 +123,48 @@ describe("pull request config parser", () => {
expect(configs.author).toEqual("another-user"); expect(configs.author).toEqual("another-user");
}); });
test("not merged pull request", async () => { test("still open pull request", async () => {
const args: Args = {
dryRun: true,
auth: "whatever",
pullRequest: openPRUrl,
targetBranch: "prod"
};
const configs: Configs = await parser.parseAndValidate(args);
expect(configs.dryRun).toEqual(true);
expect(configs.auth).toEqual("whatever");
expect(configs.targetBranch).toEqual("prod");
expect(configs.author).toEqual("gh-user");
expect(configs.originalPullRequest).toEqual({
number: 4444,
author: "gh-user",
url: "https://api.github.com/repos/owner/reponame/pulls/4444",
htmlUrl: "https://github.com/owner/reponame/pull/4444",
state: "open",
merged: false,
mergedBy: "that-s-a-user",
title: "PR Title",
body: "Please review and merge",
reviewers: ["gh-user"],
targetRepo: {
owner: "owner",
project: "reponame",
cloneUrl: "https://github.com/owner/reponame.git"
},
sourceRepo: {
owner: "fork",
project: "reponame",
cloneUrl: "https://github.com/fork/reponame.git"
},
nCommits: 2,
// taken from head.sha
commits: ["91748965051fae1330ad58d15cf694e103267c87"]
});
});
test("closed pull request", async () => {
const args: Args = { const args: Args = {
dryRun: true, dryRun: true,
auth: "whatever", auth: "whatever",
@ -127,6 +172,6 @@ describe("pull request config parser", () => {
targetBranch: "prod" targetBranch: "prod"
}; };
expect(async () => await parser.parseAndValidate(args)).rejects.toThrow("Provided pull request is not merged!"); expect(async () => await parser.parseAndValidate(args)).rejects.toThrow("Provided pull request is closed and not merged!");
}); });
}); });

View file

@ -29,7 +29,7 @@ afterEach(() => {
resetProcessArgs(); resetProcessArgs();
}); });
describe("pull request runner test", () => { describe("cli runner", () => {
test("with dry run", async () => { test("with dry run", async () => {
addProcessArgs([ addProcessArgs([
"-d", "-d",
@ -49,7 +49,8 @@ describe("pull request runner test", () => {
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1); expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0); expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1); expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
@ -77,7 +78,8 @@ describe("pull request runner test", () => {
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1); expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0); expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1); expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
@ -107,7 +109,8 @@ describe("pull request runner test", () => {
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1); expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0); expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1); expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
@ -140,7 +143,8 @@ describe("pull request runner test", () => {
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1); expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0); expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1); expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
@ -167,7 +171,8 @@ describe("pull request runner test", () => {
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1); expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0); expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1); expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
@ -188,7 +193,57 @@ describe("pull request runner test", () => {
); );
}); });
test("not merged pull request", async () => { test("same owner", async () => {
addProcessArgs([
"-tb",
"target",
"-pr",
"https://github.com/owner/reponame/pull/8632"
]);
await runner.execute();
const cwd = process.cwd() + "/bp";
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitHubService.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubService.prototype.createPullRequest).toBeCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc",
base: "target",
title: "[target] PR Title",
body: expect.stringContaining("**Backport:** https://github.com/owner/reponame/pull/8632"),
reviewers: ["gh-user", "that-s-a-user"]
}
);
});
test("closed and not merged pull request", async () => {
addProcessArgs([
"-tb",
"target",
"-pr",
"https://github.com/owner/reponame/pull/6666"
]);
expect(async () => await runner.execute()).rejects.toThrow("Provided pull request is closed and not merged!");
});
test("open pull request", async () => {
addProcessArgs([ addProcessArgs([
"-tb", "-tb",
"target", "target",
@ -196,6 +251,35 @@ describe("pull request runner test", () => {
"https://github.com/owner/reponame/pull/4444" "https://github.com/owner/reponame/pull/4444"
]); ]);
expect(async () => await runner.execute()).rejects.toThrow("Provided pull request is not merged!"); await runner.execute();
const cwd = process.cwd() + "/bp";
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-91748965051fae1330ad58d15cf694e103267c87");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/4444/head:pr/4444");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "91748965051fae1330ad58d15cf694e103267c87");
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-91748965051fae1330ad58d15cf694e103267c87");
expect(GitHubService.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubService.prototype.createPullRequest).toBeCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-91748965051fae1330ad58d15cf694e103267c87",
base: "target",
title: "[target] PR Title",
body: expect.stringContaining("**Backport:** https://github.com/owner/reponame/pull/4444"),
reviewers: ["gh-user", "that-s-a-user"]
}
);
}); });
}); });

View file

@ -26,7 +26,7 @@ afterEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
}); });
describe("pull request runner test", () => { describe("gha runner", () => {
test("with dry run", async () => { test("with dry run", async () => {
spyGetInput({ spyGetInput({
"dry-run": "true", "dry-run": "true",
@ -44,7 +44,8 @@ describe("pull request runner test", () => {
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1); expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0); expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1); expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
@ -69,7 +70,8 @@ describe("pull request runner test", () => {
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1); expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0); expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1); expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"); expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
@ -90,12 +92,50 @@ describe("pull request runner test", () => {
); );
}); });
test("not merged pull request", async () => { test("closed and not merged pull request", async () => {
spyGetInput({
"target-branch": "target",
"pull-request": "https://github.com/owner/reponame/pull/6666"
});
expect(async () => await runner.execute()).rejects.toThrow("Provided pull request is closed and not merged!");
});
test("open pull request", async () => {
spyGetInput({ spyGetInput({
"target-branch": "target", "target-branch": "target",
"pull-request": "https://github.com/owner/reponame/pull/4444" "pull-request": "https://github.com/owner/reponame/pull/4444"
}); });
expect(async () => await runner.execute()).rejects.toThrow("Provided pull request is not merged!"); await runner.execute();
const cwd = process.cwd() + "/bp";
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-91748965051fae1330ad58d15cf694e103267c87");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/4444/head:pr/4444");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "91748965051fae1330ad58d15cf694e103267c87");
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-91748965051fae1330ad58d15cf694e103267c87");
expect(GitHubService.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubService.prototype.createPullRequest).toBeCalledWith({
owner: "owner",
repo: "reponame",
head: "bp-target-91748965051fae1330ad58d15cf694e103267c87",
base: "target",
title: "[target] PR Title",
body: expect.stringContaining("**Backport:** https://github.com/owner/reponame/pull/4444"),
reviewers: ["gh-user", "that-s-a-user"]
}
);
}); });
}); });

View file

@ -466,7 +466,7 @@ export const mergedPullRequestFixture = {
"changed_files": 2 "changed_files": 2
}; };
export const notMergedPullRequestFixture = { export const openPullRequestFixture = {
"url": "https://api.github.com/repos/owner/reponame/pulls/4444", "url": "https://api.github.com/repos/owner/reponame/pulls/4444",
"id": 1137188271, "id": 1137188271,
"node_id": "PR_kwDOABTq6s5DyB2v", "node_id": "PR_kwDOABTq6s5DyB2v",
@ -475,7 +475,7 @@ export const notMergedPullRequestFixture = {
"patch_url": "https://github.com/owner/reponame/pull/4444.patch", "patch_url": "https://github.com/owner/reponame/pull/4444.patch",
"issue_url": "https://api.github.com/repos/owner/reponame/issues/4444", "issue_url": "https://api.github.com/repos/owner/reponame/issues/4444",
"number": 4444, "number": 4444,
"state": "closed", "state": "open",
"locked": false, "locked": false,
"title": "PR Title", "title": "PR Title",
"user": { "user": {
@ -908,3 +908,909 @@ export const notMergedPullRequestFixture = {
"deletions": 2, "deletions": 2,
"changed_files": 2 "changed_files": 2
}; };
export const notMergedPullRequestFixture = {
"url": "https://api.github.com/repos/owner/reponame/pulls/6666",
"id": 1137188271,
"node_id": "PR_kwDOABTq6s5DyB2v",
"html_url": "https://github.com/owner/reponame/pull/6666",
"diff_url": "https://github.com/owner/reponame/pull/6666.diff",
"patch_url": "https://github.com/owner/reponame/pull/6666.patch",
"issue_url": "https://api.github.com/repos/owner/reponame/issues/6666",
"number": 6666,
"state": "closed",
"locked": false,
"title": "PR Title",
"user": {
"login": "gh-user",
"id": 11995863,
"node_id": "MDQ6VXNlcjExOTk1ODYz",
"avatar_url": "https://avatars.githubusercontent.com/u/11995863?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gh-user",
"html_url": "https://github.com/gh-user",
"followers_url": "https://api.github.com/users/gh-user/followers",
"following_url": "https://api.github.com/users/gh-user/following{/other_user}",
"gists_url": "https://api.github.com/users/gh-user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gh-user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gh-user/subscriptions",
"organizations_url": "https://api.github.com/users/gh-user/orgs",
"repos_url": "https://api.github.com/users/gh-user/repos",
"events_url": "https://api.github.com/users/gh-user/events{/privacy}",
"received_events_url": "https://api.github.com/users/gh-user/received_events",
"type": "User",
"site_admin": false
},
"body": "Please review and merge",
"created_at": "2022-11-28T08:43:09Z",
"updated_at": "2022-11-28T10:11:53Z",
"closed_at": "2022-11-28T10:11:52Z",
"merged_at": "2022-11-28T10:11:52Z",
"merge_commit_sha": "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc",
"assignee": null,
"assignees": [
],
"requested_reviewers": [
{
"login": "gh-user",
"id": 1422582,
"node_id": "MDQ6VXNlcjE0MjI1ODI=",
"avatar_url": "https://avatars.githubusercontent.com/u/1422582?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gh-user",
"html_url": "https://github.com/gh-user",
"followers_url": "https://api.github.com/users/gh-user/followers",
"following_url": "https://api.github.com/users/gh-user/following{/other_user}",
"gists_url": "https://api.github.com/users/gh-user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gh-user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gh-user/subscriptions",
"organizations_url": "https://api.github.com/users/gh-user/orgs",
"repos_url": "https://api.github.com/users/gh-user/repos",
"events_url": "https://api.github.com/users/gh-user/events{/privacy}",
"received_events_url": "https://api.github.com/users/gh-user/received_events",
"type": "User",
"site_admin": false
}
],
"requested_teams": [
],
"labels": [
],
"milestone": null,
"draft": false,
"commits_url": "https://api.github.com/repos/owner/reponame/pulls/6666/commits",
"review_comments_url": "https://api.github.com/repos/owner/reponame/pulls/6666/comments",
"review_comment_url": "https://api.github.com/repos/owner/reponame/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/owner/reponame/issues/6666/comments",
"statuses_url": "https://api.github.com/repos/owner/reponame/statuses/91748965051fae1330ad58d15cf694e103267c87",
"head": {
"label": "kiegroup:bump-8.31.x-drools-8.31.0.Final",
"ref": "bump-8.31.x-drools-8.31.0.Final",
"sha": "91748965051fae1330ad58d15cf694e103267c87",
"user": {
"login": "kiegroup",
"id": 517980,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjUxNzk4MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/517980?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kiegroup",
"html_url": "https://github.com/kiegroup",
"followers_url": "https://api.github.com/users/kiegroup/followers",
"following_url": "https://api.github.com/users/kiegroup/following{/other_user}",
"gists_url": "https://api.github.com/users/kiegroup/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kiegroup/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kiegroup/subscriptions",
"organizations_url": "https://api.github.com/users/kiegroup/orgs",
"repos_url": "https://api.github.com/users/kiegroup/repos",
"events_url": "https://api.github.com/users/kiegroup/events{/privacy}",
"received_events_url": "https://api.github.com/users/kiegroup/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 1370858,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzcwODU4",
"name": "reponame",
"full_name": "fork/reponame",
"private": false,
"owner": {
"login": "kiegroup",
"id": 517980,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjUxNzk4MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/517980?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kiegroup",
"html_url": "https://github.com/kiegroup",
"followers_url": "https://api.github.com/users/kiegroup/followers",
"following_url": "https://api.github.com/users/kiegroup/following{/other_user}",
"gists_url": "https://api.github.com/users/kiegroup/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kiegroup/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kiegroup/subscriptions",
"organizations_url": "https://api.github.com/users/kiegroup/orgs",
"repos_url": "https://api.github.com/users/kiegroup/repos",
"events_url": "https://api.github.com/users/kiegroup/events{/privacy}",
"received_events_url": "https://api.github.com/users/kiegroup/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/fork/reponame",
"description": "AI constraint solver in Java to optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling, conference scheduling and other planning problems.",
"fork": false,
"url": "https://api.github.com/repos/fork/reponame",
"forks_url": "https://api.github.com/repos/fork/reponame/forks",
"keys_url": "https://api.github.com/repos/fork/reponame/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/fork/reponame/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/fork/reponame/teams",
"hooks_url": "https://api.github.com/repos/fork/reponame/hooks",
"issue_events_url": "https://api.github.com/repos/fork/reponame/issues/events{/number}",
"events_url": "https://api.github.com/repos/fork/reponame/events",
"assignees_url": "https://api.github.com/repos/fork/reponame/assignees{/user}",
"branches_url": "https://api.github.com/repos/fork/reponame/branches{/branch}",
"tags_url": "https://api.github.com/repos/fork/reponame/tags",
"blobs_url": "https://api.github.com/repos/fork/reponame/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/fork/reponame/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/fork/reponame/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/fork/reponame/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/fork/reponame/statuses/{sha}",
"languages_url": "https://api.github.com/repos/fork/reponame/languages",
"stargazers_url": "https://api.github.com/repos/fork/reponame/stargazers",
"contributors_url": "https://api.github.com/repos/fork/reponame/contributors",
"subscribers_url": "https://api.github.com/repos/fork/reponame/subscribers",
"subscription_url": "https://api.github.com/repos/fork/reponame/subscription",
"commits_url": "https://api.github.com/repos/fork/reponame/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/fork/reponame/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/fork/reponame/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/fork/reponame/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/fork/reponame/contents/{+path}",
"compare_url": "https://api.github.com/repos/fork/reponame/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/fork/reponame/merges",
"archive_url": "https://api.github.com/repos/fork/reponame/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/fork/reponame/downloads",
"issues_url": "https://api.github.com/repos/fork/reponame/issues{/number}",
"pulls_url": "https://api.github.com/repos/fork/reponame/pulls{/number}",
"milestones_url": "https://api.github.com/repos/fork/reponame/milestones{/number}",
"notifications_url": "https://api.github.com/repos/fork/reponame/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/fork/reponame/labels{/name}",
"releases_url": "https://api.github.com/repos/fork/reponame/releases{/id}",
"deployments_url": "https://api.github.com/repos/fork/reponame/deployments",
"created_at": "2011-02-15T19:38:23Z",
"updated_at": "2022-11-28T05:01:47Z",
"pushed_at": "2022-11-28T10:50:51Z",
"git_url": "git://github.com/fork/reponame.git",
"ssh_url": "git@github.com:fork/reponame.git",
"clone_url": "https://github.com/fork/reponame.git",
"svn_url": "https://github.com/fork/reponame",
"homepage": "https://www.reponame.org",
"size": 238339,
"stargazers_count": 2811,
"watchers_count": 2811,
"language": "Java",
"has_issues": false,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"has_discussions": false,
"forks_count": 878,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 30,
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"node_id": "MDc6TGljZW5zZTI="
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [
"artificial-intelligence",
"branch-and-bound",
"constraint-programming",
"constraint-satisfaction-problem",
"constraint-solver",
"constraints",
"employee-rostering",
"java",
"local-search",
"mathematical-optimization",
"metaheuristics",
"optimization",
"rostering",
"scheduling",
"simulated-annealing",
"solver",
"tabu-search",
"traveling-salesman",
"traveling-salesman-problem",
"vehicle-routing-problem"
],
"visibility": "public",
"forks": 878,
"open_issues": 30,
"watchers": 2811,
"default_branch": "main"
}
},
"base": {
"label": "kiegroup:8.31.x",
"ref": "8.31.x",
"sha": "8cfc286765cb01c84a1d62c65519fa8032bfecbd",
"user": {
"login": "kiegroup",
"id": 517980,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjUxNzk4MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/517980?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kiegroup",
"html_url": "https://github.com/kiegroup",
"followers_url": "https://api.github.com/users/kiegroup/followers",
"following_url": "https://api.github.com/users/kiegroup/following{/other_user}",
"gists_url": "https://api.github.com/users/kiegroup/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kiegroup/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kiegroup/subscriptions",
"organizations_url": "https://api.github.com/users/kiegroup/orgs",
"repos_url": "https://api.github.com/users/kiegroup/repos",
"events_url": "https://api.github.com/users/kiegroup/events{/privacy}",
"received_events_url": "https://api.github.com/users/kiegroup/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 1370858,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzcwODU4",
"name": "reponame",
"full_name": "owner/reponame",
"private": false,
"owner": {
"login": "kiegroup",
"id": 517980,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjUxNzk4MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/517980?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kiegroup",
"html_url": "https://github.com/kiegroup",
"followers_url": "https://api.github.com/users/kiegroup/followers",
"following_url": "https://api.github.com/users/kiegroup/following{/other_user}",
"gists_url": "https://api.github.com/users/kiegroup/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kiegroup/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kiegroup/subscriptions",
"organizations_url": "https://api.github.com/users/kiegroup/orgs",
"repos_url": "https://api.github.com/users/kiegroup/repos",
"events_url": "https://api.github.com/users/kiegroup/events{/privacy}",
"received_events_url": "https://api.github.com/users/kiegroup/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/owner/reponame",
"description": "AI constraint solver in Java to optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling, conference scheduling and other planning problems.",
"fork": false,
"url": "https://api.github.com/repos/owner/reponame",
"forks_url": "https://api.github.com/repos/owner/reponame/forks",
"keys_url": "https://api.github.com/repos/owner/reponame/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/owner/reponame/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/owner/reponame/teams",
"hooks_url": "https://api.github.com/repos/owner/reponame/hooks",
"issue_events_url": "https://api.github.com/repos/owner/reponame/issues/events{/number}",
"events_url": "https://api.github.com/repos/owner/reponame/events",
"assignees_url": "https://api.github.com/repos/owner/reponame/assignees{/user}",
"branches_url": "https://api.github.com/repos/owner/reponame/branches{/branch}",
"tags_url": "https://api.github.com/repos/owner/reponame/tags",
"blobs_url": "https://api.github.com/repos/owner/reponame/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/owner/reponame/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/owner/reponame/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/owner/reponame/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/owner/reponame/statuses/{sha}",
"languages_url": "https://api.github.com/repos/owner/reponame/languages",
"stargazers_url": "https://api.github.com/repos/owner/reponame/stargazers",
"contributors_url": "https://api.github.com/repos/owner/reponame/contributors",
"subscribers_url": "https://api.github.com/repos/owner/reponame/subscribers",
"subscription_url": "https://api.github.com/repos/owner/reponame/subscription",
"commits_url": "https://api.github.com/repos/owner/reponame/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/owner/reponame/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/owner/reponame/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/owner/reponame/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/owner/reponame/contents/{+path}",
"compare_url": "https://api.github.com/repos/owner/reponame/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/owner/reponame/merges",
"archive_url": "https://api.github.com/repos/owner/reponame/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/owner/reponame/downloads",
"issues_url": "https://api.github.com/repos/owner/reponame/issues{/number}",
"pulls_url": "https://api.github.com/repos/owner/reponame/pulls{/number}",
"milestones_url": "https://api.github.com/repos/owner/reponame/milestones{/number}",
"notifications_url": "https://api.github.com/repos/owner/reponame/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/owner/reponame/labels{/name}",
"releases_url": "https://api.github.com/repos/owner/reponame/releases{/id}",
"deployments_url": "https://api.github.com/repos/owner/reponame/deployments",
"created_at": "2011-02-15T19:38:23Z",
"updated_at": "2022-11-28T05:01:47Z",
"pushed_at": "2022-11-28T10:50:51Z",
"git_url": "git://github.com/owner/reponame.git",
"ssh_url": "git@github.com:owner/reponame.git",
"clone_url": "https://github.com/owner/reponame.git",
"svn_url": "https://github.com/owner/reponame",
"homepage": "https://www.reponame.org",
"size": 238339,
"stargazers_count": 2811,
"watchers_count": 2811,
"language": "Java",
"has_issues": false,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"has_discussions": false,
"forks_count": 878,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 30,
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"node_id": "MDc6TGljZW5zZTI="
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [
"artificial-intelligence",
"branch-and-bound",
"constraint-programming",
"constraint-satisfaction-problem",
"constraint-solver",
"constraints",
"employee-rostering",
"java",
"local-search",
"mathematical-optimization",
"metaheuristics",
"optimization",
"rostering",
"scheduling",
"simulated-annealing",
"solver",
"tabu-search",
"traveling-salesman",
"traveling-salesman-problem",
"vehicle-routing-problem"
],
"visibility": "public",
"forks": 878,
"open_issues": 30,
"watchers": 2811,
"default_branch": "main"
}
},
"_links": {
"self": {
"href": "https://api.github.com/repos/owner/reponame/pulls/6666"
},
"html": {
"href": "https://github.com/owner/reponame/pull/6666"
},
"issue": {
"href": "https://api.github.com/repos/owner/reponame/issues/6666"
},
"comments": {
"href": "https://api.github.com/repos/owner/reponame/issues/6666/comments"
},
"review_comments": {
"href": "https://api.github.com/repos/owner/reponame/pulls/6666/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/owner/reponame/pulls/comments{/number}"
},
"commits": {
"href": "https://api.github.com/repos/owner/reponame/pulls/6666/commits"
},
"statuses": {
"href": "https://api.github.com/repos/owner/reponame/statuses/91748965051fae1330ad58d15cf694e103267c87"
}
},
"author_association": "CONTRIBUTOR",
"auto_merge": null,
"active_lock_reason": null,
"merged": null,
"mergeable": null,
"rebaseable": null,
"mergeable_state": "unknown",
"merged_by": {
"login": "that-s-a-user",
"id": 17157711,
"node_id": "MDQ6VXNlcjE3MTU3NzEx",
"avatar_url": "https://avatars.githubusercontent.com/u/17157711?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/that-s-a-user",
"html_url": "https://github.com/that-s-a-user",
"followers_url": "https://api.github.com/users/that-s-a-user/followers",
"following_url": "https://api.github.com/users/that-s-a-user/following{/other_user}",
"gists_url": "https://api.github.com/users/that-s-a-user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/that-s-a-user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/that-s-a-user/subscriptions",
"organizations_url": "https://api.github.com/users/that-s-a-user/orgs",
"repos_url": "https://api.github.com/users/that-s-a-user/repos",
"events_url": "https://api.github.com/users/that-s-a-user/events{/privacy}",
"received_events_url": "https://api.github.com/users/that-s-a-user/received_events",
"type": "User",
"site_admin": false
},
"comments": 0,
"review_comments": 0,
"maintainer_can_modify": false,
"commits": 2,
"additions": 2,
"deletions": 2,
"changed_files": 2
};
export const sameOwnerPullRequestFixture = {
"url": "https://api.github.com/repos/owner/reponame/pulls/8632",
"id": 1137188271,
"node_id": "PR_kwDOABTq6s5DyB2v",
"html_url": "https://github.com/owner/reponame/pull/8632",
"diff_url": "https://github.com/owner/reponame/pull/8632.diff",
"patch_url": "https://github.com/owner/reponame/pull/8632.patch",
"issue_url": "https://api.github.com/repos/owner/reponame/issues/8632",
"number": 8632,
"state": "closed",
"locked": false,
"title": "PR Title",
"user": {
"login": "gh-user",
"id": 11995863,
"node_id": "MDQ6VXNlcjExOTk1ODYz",
"avatar_url": "https://avatars.githubusercontent.com/u/11995863?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gh-user",
"html_url": "https://github.com/gh-user",
"followers_url": "https://api.github.com/users/gh-user/followers",
"following_url": "https://api.github.com/users/gh-user/following{/other_user}",
"gists_url": "https://api.github.com/users/gh-user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gh-user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gh-user/subscriptions",
"organizations_url": "https://api.github.com/users/gh-user/orgs",
"repos_url": "https://api.github.com/users/gh-user/repos",
"events_url": "https://api.github.com/users/gh-user/events{/privacy}",
"received_events_url": "https://api.github.com/users/gh-user/received_events",
"type": "User",
"site_admin": false
},
"body": "Please review and merge",
"created_at": "2022-11-28T08:43:09Z",
"updated_at": "2022-11-28T10:11:53Z",
"closed_at": "2022-11-28T10:11:52Z",
"merged_at": "2022-11-28T10:11:52Z",
"merge_commit_sha": "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc",
"assignee": null,
"assignees": [
],
"requested_reviewers": [
{
"login": "requested-gh-user",
"id": 1422582,
"node_id": "MDQ6VXNlcjE0MjI1ODI=",
"avatar_url": "https://avatars.githubusercontent.com/u/1422582?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/requested-gh-user",
"html_url": "https://github.com/requested-gh-user",
"followers_url": "https://api.github.com/users/requested-gh-user/followers",
"following_url": "https://api.github.com/users/requested-gh-user/following{/other_user}",
"gists_url": "https://api.github.com/users/requested-gh-user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/requested-gh-user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/requested-gh-user/subscriptions",
"organizations_url": "https://api.github.com/users/requested-gh-user/orgs",
"repos_url": "https://api.github.com/users/requested-gh-user/repos",
"events_url": "https://api.github.com/users/requested-gh-user/events{/privacy}",
"received_events_url": "https://api.github.com/users/requested-gh-user/received_events",
"type": "User",
"site_admin": false
},
{
"login": "gh-user",
"id": 1422582,
"node_id": "MDQ6VXNlcjE0MjI1ODI=",
"avatar_url": "https://avatars.githubusercontent.com/u/1422582?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/gh-user",
"html_url": "https://github.com/gh-user",
"followers_url": "https://api.github.com/users/gh-user/followers",
"following_url": "https://api.github.com/users/gh-user/following{/other_user}",
"gists_url": "https://api.github.com/users/gh-user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/gh-user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/gh-user/subscriptions",
"organizations_url": "https://api.github.com/users/gh-user/orgs",
"repos_url": "https://api.github.com/users/gh-user/repos",
"events_url": "https://api.github.com/users/gh-user/events{/privacy}",
"received_events_url": "https://api.github.com/users/gh-user/received_events",
"type": "User",
"site_admin": false
}
],
"requested_teams": [
],
"labels": [
],
"milestone": null,
"draft": false,
"commits_url": "https://api.github.com/repos/owner/reponame/pulls/8632/commits",
"review_comments_url": "https://api.github.com/repos/owner/reponame/pulls/8632/comments",
"review_comment_url": "https://api.github.com/repos/owner/reponame/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/owner/reponame/issues/8632/comments",
"statuses_url": "https://api.github.com/repos/owner/reponame/statuses/91748965051fae1330ad58d15cf694e103267c87",
"head": {
"label": "kiegroup:bump-8.31.x-drools-8.31.0.Final",
"ref": "bump-8.31.x-drools-8.31.0.Final",
"sha": "91748965051fae1330ad58d15cf694e103267c87",
"user": {
"login": "kiegroup",
"id": 517980,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjUxNzk4MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/517980?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kiegroup",
"html_url": "https://github.com/kiegroup",
"followers_url": "https://api.github.com/users/kiegroup/followers",
"following_url": "https://api.github.com/users/kiegroup/following{/other_user}",
"gists_url": "https://api.github.com/users/kiegroup/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kiegroup/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kiegroup/subscriptions",
"organizations_url": "https://api.github.com/users/kiegroup/orgs",
"repos_url": "https://api.github.com/users/kiegroup/repos",
"events_url": "https://api.github.com/users/kiegroup/events{/privacy}",
"received_events_url": "https://api.github.com/users/kiegroup/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 1370858,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzcwODU4",
"name": "reponame",
"full_name": "owner/reponame",
"private": false,
"owner": {
"login": "kiegroup",
"id": 517980,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjUxNzk4MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/517980?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kiegroup",
"html_url": "https://github.com/kiegroup",
"followers_url": "https://api.github.com/users/kiegroup/followers",
"following_url": "https://api.github.com/users/kiegroup/following{/other_user}",
"gists_url": "https://api.github.com/users/kiegroup/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kiegroup/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kiegroup/subscriptions",
"organizations_url": "https://api.github.com/users/kiegroup/orgs",
"repos_url": "https://api.github.com/users/kiegroup/repos",
"events_url": "https://api.github.com/users/kiegroup/events{/privacy}",
"received_events_url": "https://api.github.com/users/kiegroup/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/owner/reponame",
"description": "AI constraint solver in Java to optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling, conference scheduling and other planning problems.",
"fork": false,
"url": "https://api.github.com/repos/owner/reponame",
"forks_url": "https://api.github.com/repos/owner/reponame/forks",
"keys_url": "https://api.github.com/repos/owner/reponame/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/owner/reponame/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/owner/reponame/teams",
"hooks_url": "https://api.github.com/repos/owner/reponame/hooks",
"issue_events_url": "https://api.github.com/repos/owner/reponame/issues/events{/number}",
"events_url": "https://api.github.com/repos/owner/reponame/events",
"assignees_url": "https://api.github.com/repos/owner/reponame/assignees{/user}",
"branches_url": "https://api.github.com/repos/owner/reponame/branches{/branch}",
"tags_url": "https://api.github.com/repos/owner/reponame/tags",
"blobs_url": "https://api.github.com/repos/owner/reponame/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/owner/reponame/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/owner/reponame/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/owner/reponame/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/owner/reponame/statuses/{sha}",
"languages_url": "https://api.github.com/repos/owner/reponame/languages",
"stargazers_url": "https://api.github.com/repos/owner/reponame/stargazers",
"contributors_url": "https://api.github.com/repos/owner/reponame/contributors",
"subscribers_url": "https://api.github.com/repos/owner/reponame/subscribers",
"subscription_url": "https://api.github.com/repos/owner/reponame/subscription",
"commits_url": "https://api.github.com/repos/owner/reponame/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/owner/reponame/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/owner/reponame/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/owner/reponame/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/owner/reponame/contents/{+path}",
"compare_url": "https://api.github.com/repos/owner/reponame/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/owner/reponame/merges",
"archive_url": "https://api.github.com/repos/owner/reponame/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/owner/reponame/downloads",
"issues_url": "https://api.github.com/repos/owner/reponame/issues{/number}",
"pulls_url": "https://api.github.com/repos/owner/reponame/pulls{/number}",
"milestones_url": "https://api.github.com/repos/owner/reponame/milestones{/number}",
"notifications_url": "https://api.github.com/repos/owner/reponame/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/owner/reponame/labels{/name}",
"releases_url": "https://api.github.com/repos/owner/reponame/releases{/id}",
"deployments_url": "https://api.github.com/repos/owner/reponame/deployments",
"created_at": "2011-02-15T19:38:23Z",
"updated_at": "2022-11-28T05:01:47Z",
"pushed_at": "2022-11-28T10:50:51Z",
"git_url": "git://github.com/owner/reponame.git",
"ssh_url": "git@github.com:owner/reponame.git",
"clone_url": "https://github.com/owner/reponame.git",
"svn_url": "https://github.com/owner/reponame",
"homepage": "https://www.reponame.org",
"size": 238339,
"stargazers_count": 2811,
"watchers_count": 2811,
"language": "Java",
"has_issues": false,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"has_discussions": false,
"forks_count": 878,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 30,
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"node_id": "MDc6TGljZW5zZTI="
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [
"artificial-intelligence",
"branch-and-bound",
"constraint-programming",
"constraint-satisfaction-problem",
"constraint-solver",
"constraints",
"employee-rostering",
"java",
"local-search",
"mathematical-optimization",
"metaheuristics",
"optimization",
"rostering",
"scheduling",
"simulated-annealing",
"solver",
"tabu-search",
"traveling-salesman",
"traveling-salesman-problem",
"vehicle-routing-problem"
],
"visibility": "public",
"forks": 878,
"open_issues": 30,
"watchers": 2811,
"default_branch": "main"
}
},
"base": {
"label": "kiegroup:8.31.x",
"ref": "8.31.x",
"sha": "8cfc286765cb01c84a1d62c65519fa8032bfecbd",
"user": {
"login": "kiegroup",
"id": 517980,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjUxNzk4MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/517980?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kiegroup",
"html_url": "https://github.com/kiegroup",
"followers_url": "https://api.github.com/users/kiegroup/followers",
"following_url": "https://api.github.com/users/kiegroup/following{/other_user}",
"gists_url": "https://api.github.com/users/kiegroup/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kiegroup/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kiegroup/subscriptions",
"organizations_url": "https://api.github.com/users/kiegroup/orgs",
"repos_url": "https://api.github.com/users/kiegroup/repos",
"events_url": "https://api.github.com/users/kiegroup/events{/privacy}",
"received_events_url": "https://api.github.com/users/kiegroup/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 1370858,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzcwODU4",
"name": "reponame",
"full_name": "owner/reponame",
"private": false,
"owner": {
"login": "kiegroup",
"id": 517980,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjUxNzk4MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/517980?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kiegroup",
"html_url": "https://github.com/kiegroup",
"followers_url": "https://api.github.com/users/kiegroup/followers",
"following_url": "https://api.github.com/users/kiegroup/following{/other_user}",
"gists_url": "https://api.github.com/users/kiegroup/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kiegroup/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kiegroup/subscriptions",
"organizations_url": "https://api.github.com/users/kiegroup/orgs",
"repos_url": "https://api.github.com/users/kiegroup/repos",
"events_url": "https://api.github.com/users/kiegroup/events{/privacy}",
"received_events_url": "https://api.github.com/users/kiegroup/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/owner/reponame",
"description": "AI constraint solver in Java to optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling, conference scheduling and other planning problems.",
"fork": false,
"url": "https://api.github.com/repos/owner/reponame",
"forks_url": "https://api.github.com/repos/owner/reponame/forks",
"keys_url": "https://api.github.com/repos/owner/reponame/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/owner/reponame/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/owner/reponame/teams",
"hooks_url": "https://api.github.com/repos/owner/reponame/hooks",
"issue_events_url": "https://api.github.com/repos/owner/reponame/issues/events{/number}",
"events_url": "https://api.github.com/repos/owner/reponame/events",
"assignees_url": "https://api.github.com/repos/owner/reponame/assignees{/user}",
"branches_url": "https://api.github.com/repos/owner/reponame/branches{/branch}",
"tags_url": "https://api.github.com/repos/owner/reponame/tags",
"blobs_url": "https://api.github.com/repos/owner/reponame/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/owner/reponame/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/owner/reponame/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/owner/reponame/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/owner/reponame/statuses/{sha}",
"languages_url": "https://api.github.com/repos/owner/reponame/languages",
"stargazers_url": "https://api.github.com/repos/owner/reponame/stargazers",
"contributors_url": "https://api.github.com/repos/owner/reponame/contributors",
"subscribers_url": "https://api.github.com/repos/owner/reponame/subscribers",
"subscription_url": "https://api.github.com/repos/owner/reponame/subscription",
"commits_url": "https://api.github.com/repos/owner/reponame/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/owner/reponame/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/owner/reponame/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/owner/reponame/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/owner/reponame/contents/{+path}",
"compare_url": "https://api.github.com/repos/owner/reponame/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/owner/reponame/merges",
"archive_url": "https://api.github.com/repos/owner/reponame/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/owner/reponame/downloads",
"issues_url": "https://api.github.com/repos/owner/reponame/issues{/number}",
"pulls_url": "https://api.github.com/repos/owner/reponame/pulls{/number}",
"milestones_url": "https://api.github.com/repos/owner/reponame/milestones{/number}",
"notifications_url": "https://api.github.com/repos/owner/reponame/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/owner/reponame/labels{/name}",
"releases_url": "https://api.github.com/repos/owner/reponame/releases{/id}",
"deployments_url": "https://api.github.com/repos/owner/reponame/deployments",
"created_at": "2011-02-15T19:38:23Z",
"updated_at": "2022-11-28T05:01:47Z",
"pushed_at": "2022-11-28T10:50:51Z",
"git_url": "git://github.com/owner/reponame.git",
"ssh_url": "git@github.com:owner/reponame.git",
"clone_url": "https://github.com/owner/reponame.git",
"svn_url": "https://github.com/owner/reponame",
"homepage": "https://www.reponame.org",
"size": 238339,
"stargazers_count": 2811,
"watchers_count": 2811,
"language": "Java",
"has_issues": false,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"has_discussions": false,
"forks_count": 878,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 30,
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"node_id": "MDc6TGljZW5zZTI="
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [
"artificial-intelligence",
"branch-and-bound",
"constraint-programming",
"constraint-satisfaction-problem",
"constraint-solver",
"constraints",
"employee-rostering",
"java",
"local-search",
"mathematical-optimization",
"metaheuristics",
"optimization",
"rostering",
"scheduling",
"simulated-annealing",
"solver",
"tabu-search",
"traveling-salesman",
"traveling-salesman-problem",
"vehicle-routing-problem"
],
"visibility": "public",
"forks": 878,
"open_issues": 30,
"watchers": 2811,
"default_branch": "main"
}
},
"_links": {
"self": {
"href": "https://api.github.com/repos/owner/reponame/pulls/8632"
},
"html": {
"href": "https://github.com/owner/reponame/pull/8632"
},
"issue": {
"href": "https://api.github.com/repos/owner/reponame/issues/8632"
},
"comments": {
"href": "https://api.github.com/repos/owner/reponame/issues/8632/comments"
},
"review_comments": {
"href": "https://api.github.com/repos/owner/reponame/pulls/8632/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/owner/reponame/pulls/comments{/number}"
},
"commits": {
"href": "https://api.github.com/repos/owner/reponame/pulls/8632/commits"
},
"statuses": {
"href": "https://api.github.com/repos/owner/reponame/statuses/91748965051fae1330ad58d15cf694e103267c87"
}
},
"author_association": "CONTRIBUTOR",
"auto_merge": null,
"active_lock_reason": null,
"merged": true,
"mergeable": null,
"rebaseable": null,
"mergeable_state": "unknown",
"merged_by": {
"login": "that-s-a-user",
"id": 17157711,
"node_id": "MDQ6VXNlcjE3MTU3NzEx",
"avatar_url": "https://avatars.githubusercontent.com/u/17157711?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/that-s-a-user",
"html_url": "https://github.com/that-s-a-user",
"followers_url": "https://api.github.com/users/that-s-a-user/followers",
"following_url": "https://api.github.com/users/that-s-a-user/following{/other_user}",
"gists_url": "https://api.github.com/users/that-s-a-user/gists{/gist_id}",
"starred_url": "https://api.github.com/users/that-s-a-user/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/that-s-a-user/subscriptions",
"organizations_url": "https://api.github.com/users/that-s-a-user/orgs",
"repos_url": "https://api.github.com/users/that-s-a-user/repos",
"events_url": "https://api.github.com/users/that-s-a-user/events{/privacy}",
"received_events_url": "https://api.github.com/users/that-s-a-user/received_events",
"type": "User",
"site_admin": false
},
"comments": 0,
"review_comments": 0,
"maintainer_can_modify": false,
"commits": 2,
"additions": 2,
"deletions": 2,
"changed_files": 2
};

View file

@ -1,6 +1,6 @@
import LoggerServiceFactory from "@bp/service/logger/logger-service-factory"; import LoggerServiceFactory from "@bp/service/logger/logger-service-factory";
import { Moctokit } from "@kie/mock-github"; import { Moctokit } from "@kie/mock-github";
import { targetOwner, repo, mergedPullRequestFixture, notMergedPullRequestFixture, notFoundPullRequestNumber } from "./moctokit-data"; import { targetOwner, repo, mergedPullRequestFixture, openPullRequestFixture, notMergedPullRequestFixture, notFoundPullRequestNumber, sameOwnerPullRequestFixture } from "./moctokit-data";
const logger = LoggerServiceFactory.getLogger(); const logger = LoggerServiceFactory.getLogger();
@ -23,6 +23,28 @@ export const setupMoctokit = (): Moctokit => {
data: mergedPullRequestFixture data: mergedPullRequestFixture
}); });
mock.rest.pulls
.get({
owner: targetOwner,
repo: repo,
pull_number: sameOwnerPullRequestFixture.number
})
.reply({
status: 200,
data: sameOwnerPullRequestFixture
});
mock.rest.pulls
.get({
owner: targetOwner,
repo: repo,
pull_number: openPullRequestFixture.number
})
.reply({
status: 200,
data: openPullRequestFixture
});
mock.rest.pulls mock.rest.pulls
.get({ .get({
owner: targetOwner, owner: targetOwner,