mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-15 10:09:12 -04:00
feat(issue-54): backport pr commits without squash (#55)
* feat(issue-54): backport pr commits without squash fix https://github.com/kiegroup/git-backporting/issues/54 * feat(issue-54): fixed readme
This commit is contained in:
parent
a737aa7c4c
commit
c4dbb26c1d
29 changed files with 990 additions and 145 deletions
|
@ -1,7 +1,7 @@
|
|||
import LoggerServiceFactory from "@bp/service/logger/logger-service-factory";
|
||||
import { Moctokit } from "@kie/mock-github";
|
||||
import { targetOwner, repo, mergedPullRequestFixture, openPullRequestFixture, notMergedPullRequestFixture, notFoundPullRequestNumber, sameOwnerPullRequestFixture } from "./github-data";
|
||||
import { CLOSED_NOT_MERGED_MR, MERGED_SQUASHED_MR, OPEN_MR, PROJECT_EXAMPLE, SUPERUSER} from "./gitlab-data";
|
||||
import { targetOwner, repo, mergedPullRequestFixture, openPullRequestFixture, notMergedPullRequestFixture, notFoundPullRequestNumber, multipleCommitsPullRequestFixture, multipleCommitsPullRequestCommits } from "./github-data";
|
||||
import { CLOSED_NOT_MERGED_MR, MERGED_SQUASHED_MR, OPEN_MR, OPEN_PR_COMMITS, PROJECT_EXAMPLE, SUPERUSER} from "./gitlab-data";
|
||||
|
||||
const logger = LoggerServiceFactory.getLogger();
|
||||
|
||||
|
@ -22,6 +22,8 @@ export const getAxiosMocked = (url: string) => {
|
|||
data = PROJECT_EXAMPLE;
|
||||
} else if (url.endsWith("users?username=superuser")) {
|
||||
data = [SUPERUSER];
|
||||
} else if (url.endsWith("merge_requests/2/commits")) {
|
||||
data = OPEN_PR_COMMITS;
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -96,15 +98,15 @@ export const mockGitHubClient = (apiUrl = "https://api.github.com"): Moctokit =>
|
|||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: sameOwnerPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: sameOwnerPullRequestFixture
|
||||
});
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: multipleCommitsPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: multipleCommitsPullRequestFixture
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
|
@ -118,15 +120,26 @@ export const mockGitHubClient = (apiUrl = "https://api.github.com"): Moctokit =>
|
|||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: notMergedPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: notMergedPullRequestFixture
|
||||
});
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: notMergedPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: notMergedPullRequestFixture
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.listCommits({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: multipleCommitsPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: multipleCommitsPullRequestCommits
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.create()
|
||||
|
@ -156,7 +169,6 @@ export const mockGitHubClient = (apiUrl = "https://api.github.com"): Moctokit =>
|
|||
data: {}
|
||||
});
|
||||
|
||||
|
||||
// invalid requests
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
|
|
|
@ -1341,7 +1341,7 @@ export const notMergedPullRequestFixture = {
|
|||
"changed_files": 2
|
||||
};
|
||||
|
||||
export const sameOwnerPullRequestFixture = {
|
||||
export const multipleCommitsPullRequestFixture = {
|
||||
"url": "https://api.github.com/repos/owner/reponame/pulls/8632",
|
||||
"id": 1137188271,
|
||||
"node_id": "PR_kwDOABTq6s5DyB2v",
|
||||
|
@ -1802,4 +1802,165 @@ export const sameOwnerPullRequestFixture = {
|
|||
"additions": 2,
|
||||
"deletions": 2,
|
||||
"changed_files": 2
|
||||
};
|
||||
};
|
||||
|
||||
export const multipleCommitsPullRequestCommits = [
|
||||
{
|
||||
"sha": "0404fb922ab75c3a8aecad5c97d9af388df04695",
|
||||
"node_id": "C_kwDOImgs99oAKDA0MDRmYjkyMmFiNzVjM2E4YWVjYWQ1Yzk3ZDlhZjM4OGRmMDQ2OTU",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "owner",
|
||||
"email": "owner@email.com",
|
||||
"date": "2023-07-06T13:46:30Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "GitHub",
|
||||
"email": "noreply@github.com",
|
||||
"date": "2023-07-06T13:46:30Z"
|
||||
},
|
||||
"message": "Update file1.txt",
|
||||
"tree": {
|
||||
"sha": "50be1d7031b02a2ae609f432f2a1e0f818d827b2",
|
||||
"url": "https://api.github.com/repos/owner/reponame/git/trees/50be1d7031b02a2ae609f432f2a1e0f818d827b2"
|
||||
},
|
||||
"url": "https://api.github.com/repos/owner/reponame/git/commits/0404fb922ab75c3a8aecad5c97d9af388df04695",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": true,
|
||||
"reason": "valid",
|
||||
"signature": "-----BEGIN PGP SIGNATURE-----\n\nno-signature=\n=fivd\n-----END PGP SIGNATURE-----\n",
|
||||
"payload": "tree 50be1d7031b02a2ae609f432f2a1e0f818d827b2\nparent c85b8fcdb741814b3e90e6e5729455cf46ff26ea\nauthor Owner <owner@email.com> 1688651190 +0200\ncommitter GitHub <noreply@github.com> 1688651190 +0200\n\nUpdate file1.txt"
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/owner/reponame/commits/0404fb922ab75c3a8aecad5c97d9af388df04695",
|
||||
"html_url": "https://github.com/owner/reponame/commit/0404fb922ab75c3a8aecad5c97d9af388df04695",
|
||||
"comments_url": "https://api.github.com/repos/owner/reponame/commits/0404fb922ab75c3a8aecad5c97d9af388df04695/comments",
|
||||
"author": {
|
||||
"login": "owner",
|
||||
"id": 26715795,
|
||||
"node_id": "MDQ6VXNlcjI2NzE1Nzk1",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/26715795?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/owner",
|
||||
"html_url": "https://github.com/owner",
|
||||
"followers_url": "https://api.github.com/users/owner/followers",
|
||||
"following_url": "https://api.github.com/users/owner/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/owner/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/owner/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/owner/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/owner/orgs",
|
||||
"repos_url": "https://api.github.com/users/owner/repos",
|
||||
"events_url": "https://api.github.com/users/owner/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/owner/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "web-flow",
|
||||
"id": 19864447,
|
||||
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/web-flow",
|
||||
"html_url": "https://github.com/web-flow",
|
||||
"followers_url": "https://api.github.com/users/web-flow/followers",
|
||||
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/web-flow/orgs",
|
||||
"repos_url": "https://api.github.com/users/web-flow/repos",
|
||||
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/web-flow/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [
|
||||
{
|
||||
"sha": "c85b8fcdb741814b3e90e6e5729455cf46ff26ea",
|
||||
"url": "https://api.github.com/repos/owner/reponame/commits/c85b8fcdb741814b3e90e6e5729455cf46ff26ea",
|
||||
"html_url": "https://github.com/owner/reponame/commit/c85b8fcdb741814b3e90e6e5729455cf46ff26ea"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"sha": "11da4e38aa3e577ffde6d546f1c52e53b04d3151",
|
||||
"node_id": "C_kwDOImgs99oAKDExZGE0ZTM4YWEzZTU3N2ZmZGU2ZDU0NmYxYzUyZTUzYjA0ZDMxNTE",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "Owner",
|
||||
"email": "owner@email.com",
|
||||
"date": "2023-07-10T13:23:44Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "GitHub",
|
||||
"email": "noreply@github.com",
|
||||
"date": "2023-07-10T13:23:44Z"
|
||||
},
|
||||
"message": "Update file2.txt",
|
||||
"tree": {
|
||||
"sha": "fdd16fb791eef26fd84c3bfa34fd89eb1f7a85be",
|
||||
"url": "https://api.github.com/repos/owner/reponame/git/trees/fdd16fb791eef26fd84c3bfa34fd89eb1f7a85be"
|
||||
},
|
||||
"url": "https://api.github.com/repos/owner/reponame/git/commits/11da4e38aa3e577ffde6d546f1c52e53b04d3151",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": true,
|
||||
"reason": "valid",
|
||||
"signature": "-----BEGIN PGP SIGNATURE-----\n\nno-signature\n=//hm\n-----END PGP SIGNATURE-----\n",
|
||||
"payload": "tree fdd16fb791eef26fd84c3bfa34fd89eb1f7a85be\nparent 0404fb922ab75c3a8aecad5c97d9af388df04695\nauthor Owner <owner@email.com> 1688995424 +0200\ncommitter GitHub <noreply@github.com> 1688995424 +0200\n\nUpdate file2.txt"
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/owner/reponame/commits/11da4e38aa3e577ffde6d546f1c52e53b04d3151",
|
||||
"html_url": "https://github.com/owner/reponame/commit/11da4e38aa3e577ffde6d546f1c52e53b04d3151",
|
||||
"comments_url": "https://api.github.com/repos/owner/reponame/commits/11da4e38aa3e577ffde6d546f1c52e53b04d3151/comments",
|
||||
"author": {
|
||||
"login": "owner",
|
||||
"id": 26715795,
|
||||
"node_id": "MDQ6VXNlcjI2NzE1Nzk1",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/26715795?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/owner",
|
||||
"html_url": "https://github.com/owner",
|
||||
"followers_url": "https://api.github.com/users/owner/followers",
|
||||
"following_url": "https://api.github.com/users/owner/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/owner/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/owner/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/owner/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/owner/orgs",
|
||||
"repos_url": "https://api.github.com/users/owner/repos",
|
||||
"events_url": "https://api.github.com/users/owner/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/owner/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "web-flow",
|
||||
"id": 19864447,
|
||||
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/web-flow",
|
||||
"html_url": "https://github.com/web-flow",
|
||||
"followers_url": "https://api.github.com/users/web-flow/followers",
|
||||
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/web-flow/orgs",
|
||||
"repos_url": "https://api.github.com/users/web-flow/repos",
|
||||
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/web-flow/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [
|
||||
{
|
||||
"sha": "0404fb922ab75c3a8aecad5c97d9af388df04695",
|
||||
"url": "https://api.github.com/repos/owner/reponame/commits/0404fb922ab75c3a8aecad5c97d9af388df04695",
|
||||
"html_url": "https://github.com/owner/reponame/commit/0404fb922ab75c3a8aecad5c97d9af388df04695"
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
|
@ -529,6 +529,49 @@ export const CLOSED_NOT_MERGED_MR = {
|
|||
}
|
||||
};
|
||||
|
||||
export const OPEN_PR_COMMITS = [
|
||||
{
|
||||
"id":"974519f65c9e0ed65277cd71026657a09fca05e7",
|
||||
"short_id":"974519f6",
|
||||
"created_at":"2023-07-10T19:23:04.000Z",
|
||||
"parent_ids":[
|
||||
|
||||
],
|
||||
"title":"Add another file",
|
||||
"message":"Add another file",
|
||||
"author_name":"Super User",
|
||||
"author_email":"superuser@email.com",
|
||||
"authored_date":"2023-07-10T19:23:04.000Z",
|
||||
"committer_name":"Super User",
|
||||
"committer_email":"superuser@email.com",
|
||||
"committed_date":"2023-07-10T19:23:04.000Z",
|
||||
"trailers":{
|
||||
|
||||
},
|
||||
"web_url":"https://gitlab.com/superuser/backporting-example/-/commit/974519f65c9e0ed65277cd71026657a09fca05e7"
|
||||
},
|
||||
{
|
||||
"id":"e4dd336a4a20f394df6665994df382fb1d193a11",
|
||||
"short_id":"e4dd336a",
|
||||
"created_at":"2023-06-29T09:59:10.000Z",
|
||||
"parent_ids":[
|
||||
|
||||
],
|
||||
"title":"Add new file",
|
||||
"message":"Add new file",
|
||||
"author_name":"Super User",
|
||||
"author_email":"superuser@email.com",
|
||||
"authored_date":"2023-06-29T09:59:10.000Z",
|
||||
"committer_name":"Super User",
|
||||
"committer_email":"superuser@email.com",
|
||||
"committed_date":"2023-06-29T09:59:10.000Z",
|
||||
"trailers":{
|
||||
|
||||
},
|
||||
"web_url":"https://gitlab.com/superuser/backporting-example/-/commit/e4dd336a4a20f394df6665994df382fb1d193a11"
|
||||
}
|
||||
];
|
||||
|
||||
export const SUPERUSER = {
|
||||
"id":14041,
|
||||
"username":"superuser",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue