mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-10 15:49:13 -04:00
fix(issue-57): truncate the bp branch name (#58)
fix: https://github.com/kiegroup/git-backporting/issues/57 This pr will ensure that if the provided/generated backport branch name exceede the maximum branch name length set for git, which is 250 chars, it truncates that name to 250 chars exactly. In order to include as much commits as possible the branch name will contain by default the shortened version of all commits
This commit is contained in:
parent
91782505ce
commit
ead1322c0f
8 changed files with 169 additions and 88 deletions
|
@ -85,7 +85,7 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.clone).toBeCalledWith("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-9e15674ebd48e05c6e428a1fa31dbb60a778d644");
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-9e15674");
|
||||
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
@ -114,7 +114,7 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.clone).toBeCalledWith("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-9e15674ebd48e05c6e428a1fa31dbb60a778d644");
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-9e15674");
|
||||
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
@ -123,13 +123,13 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644");
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9e15674ebd48e05c6e428a1fa31dbb60a778d644");
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9e15674");
|
||||
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
|
||||
owner: "superuser",
|
||||
repo: "backporting-example",
|
||||
head: "bp-target-9e15674ebd48e05c6e428a1fa31dbb60a778d644",
|
||||
head: "bp-target-9e15674",
|
||||
base: "target",
|
||||
title: "[target] Update test.txt opened",
|
||||
body: expect.stringContaining("**Backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/2"),
|
||||
|
@ -166,7 +166,7 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.clone).toBeCalledWith("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-ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
|
@ -174,13 +174,13 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
|
||||
owner: "superuser",
|
||||
repo: "backporting-example",
|
||||
head: "bp-target-ebb1eca696c42fd067658bd9b5267709f78ef38e",
|
||||
head: "bp-target-ebb1eca",
|
||||
base: "target",
|
||||
title: "[target] Update test.txt",
|
||||
body: expect.stringContaining("**Backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1"),
|
||||
|
@ -309,7 +309,7 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.clone).toBeCalledWith("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-ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
|
@ -317,13 +317,13 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
|
||||
owner: "superuser",
|
||||
repo: "backporting-example",
|
||||
head: "bp-target-ebb1eca696c42fd067658bd9b5267709f78ef38e",
|
||||
head: "bp-target-ebb1eca",
|
||||
base: "target",
|
||||
title: "[target] Update test.txt",
|
||||
body: expect.stringContaining("**Backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1"),
|
||||
|
@ -352,7 +352,7 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.clone).toBeCalledWith("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-ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
|
@ -360,13 +360,13 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
|
||||
owner: "superuser",
|
||||
repo: "backporting-example",
|
||||
head: "bp-target-ebb1eca696c42fd067658bd9b5267709f78ef38e",
|
||||
head: "bp-target-ebb1eca",
|
||||
base: "target",
|
||||
title: "[target] Update test.txt",
|
||||
body: expect.stringContaining("**Backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1"),
|
||||
|
@ -393,7 +393,7 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.clone).toBeCalledWith("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-ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-prod-ebb1eca");
|
||||
|
||||
// 0 occurrences as the mr is already merged and the owner is the same for
|
||||
// both source and target repositories
|
||||
|
@ -403,13 +403,13 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-prod-ebb1eca696c42fd067658bd9b5267709f78ef38e");
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-prod-ebb1eca");
|
||||
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
|
||||
owner: "superuser",
|
||||
repo: "backporting-example",
|
||||
head: "bp-prod-ebb1eca696c42fd067658bd9b5267709f78ef38e",
|
||||
head: "bp-prod-ebb1eca",
|
||||
base: "prod",
|
||||
title: "New Title",
|
||||
body: expect.stringContaining("**This is a backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1"),
|
||||
|
@ -438,7 +438,7 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.clone).toBeCalledWith("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-e4dd336a4a20f394df6665994df382fb1d193a11-974519f65c9e0ed65277cd71026657a09fca05e7");
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336-974519f");
|
||||
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
@ -448,13 +448,13 @@ describe("gha runner", () => {
|
|||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "974519f65c9e0ed65277cd71026657a09fca05e7");
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336a4a20f394df6665994df382fb1d193a11-974519f65c9e0ed65277cd71026657a09fca05e7");
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336-974519f");
|
||||
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(1);
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledWith({
|
||||
owner: "superuser",
|
||||
repo: "backporting-example",
|
||||
head: "bp-target-e4dd336a4a20f394df6665994df382fb1d193a11-974519f65c9e0ed65277cd71026657a09fca05e7",
|
||||
head: "bp-target-e4dd336-974519f",
|
||||
base: "target",
|
||||
title: "[target] Update test.txt opened",
|
||||
body: expect.stringContaining("**Backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/2"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue