Skip to content

feat: add ability to open PRs from forked repo - #216

Merged
lampajr merged 1 commit into
kiegroup:mainfrom
BtbN:forked_prs
Jul 25, 2026
Merged

feat: add ability to open PRs from forked repo#216
lampajr merged 1 commit into
kiegroup:mainfrom
BtbN:forked_prs

Conversation

@BtbN

@BtbN BtbN commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #27

Description

This adds the ability to have the backport PRs be opened from a separate repository, so the main repository stays clean of backport branches.
This will not work with the automatic actions token. So a manually created PAT for some Bot-Account needs to be provided via secrets, and a forked repo under its control has to exist.

How Has This Been Tested?

Notably, the gitlab part is untested.
Otherwise, this has been deployed to our Forgejo instance at code.ffmpeg.org and has successfully opened backport PRs like https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23855

Checklist

  • Tests added if applicable.
  • Documentation updated if applicable.

Merge criteria:

  • The commits and have meaningful messages; the author will squash them after approval or will ask to merge with squash.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
89.39% (+0.02% 🔼)
573/641
🟢 Branches
85% (-0.48% 🔻)
272/320
🟢 Functions
87.66% (-0.26% 🔻)
135/154
🟢 Lines
89.21% (-0.01% 🔻)
554/621
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢 runner/runner.ts
89.43% (-0.31% 🔻)
93.02% (-1.98% 🔻)
85.19% (-2.81% 🔻)
89.43% (-0.31% 🔻)
🟢
... / pr-configs-parser.ts
97.33% (-1.05% 🔻)
95.71% (-1.16% 🔻)
100%
97.18% (-1.15% 🔻)
🟢
... / gitlab-client.ts
85.26% (+0.16% 🔼)
76% (-4.95% 🔻)
88%
84.62% (+0.17% 🔼)

Test suite run success

220 tests passing in 18 suites.

Report generated by 🧪jest coverage report action from b2f17a8

@lampajr lampajr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @BtbN , Thanks a lot for the PR ❤️

Overall looks great, I left a couple of comments here and there. Happy to hear what you think :)

Comment thread src/service/git/git.types.ts Outdated
Comment thread src/service/runner/runner.ts Outdated
Comment on lines +194 to +198
if (backportPR.pushRemoteUrl) {
await git.gitCli.push(configs.folder, backportPR.head, backportPR.pushRemoteUrl);
} else {
await git.gitCli.push(configs.folder, backportPR.head);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to have the if-else here, if the pushRemoteUrl is undefined the gitCli.push should fallback to origin by default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this construct, there was A LOT of noise in the tests, since they check for this function being called with two parameters in a lot of places.
So I decided for this method to keep the patch footprint low.
I can also update all the tests if that's preferred.

Comment thread src/service/configs/pullrequest/pr-configs-parser.ts Outdated

const sanitized = bpRepo.trim();
const parts = sanitized.split("/").map(p => p.trim()).filter(p => p.length > 0);
if (parts.length !== 2) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a limitation on Gitlab side where we can have nested paths. We can leave it as it is for now and improve it in some follow-up once we can validate on Gitlab side. Commenting just for trackign purposes.

Comment thread src/service/git/git-cli.ts Outdated
options.push("--force-with-lease");
}
await this.git(cwd).push(remote, branch, options);
await this.git(cwd).push(this.remoteWithAuth(remote), branch, options);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of running push with token auth which is not needed in the case of origin, as the token is already embedded in the remote - have you considered following a similar approach sued for origin? i.e., call addRemote to add the fork remote using the auth token so that here we don't need this explicit remoteWithAuth call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both approaches worked fine when I tested it.
The forked repos remote was just only used in a single place, and push happily pushes to a direct URL.
And since named remote names won't ever contain ://, this seemed a practical solution to me.
I can also change it to first add a named remote, and then push to that if preferred.

Comment thread src/service/runner/runner.ts Outdated
Comment thread README.md

@lampajr lampajr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

thanks a lot @BtbN ❤️

@lampajr

lampajr commented Jul 25, 2026

Copy link
Copy Markdown
Member

I will merge it and then we can follow up with some fixes / improvements if needed

@lampajr
lampajr merged commit da19e2a into kiegroup:main Jul 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Pull Request from Forked Repo

2 participants