Really what I am looking for ultimately is not this, but since I found no actual solution to my problem, then I thought a patch was a way to go.
What I am really trying is:
- There is a PR on GitHub. GitHub is a mirror of our actual GitLab repo.
- I want to export the GitHub PR to GitLab MR and treat the MR in Gitlab
- Once merged in GitLab the original GitHub PR should be automatically marked as “merged”.
I wanted to use the API for this, and since I found no way to fetch the full PR with all its commits etc from Github and create a GitLab MR of it (maybe I just did not understand how to) then I thought to transfer the commits one by one and commit to a new branch in GitLab. But then it would be nice just to use the patches.
So the scenario would be
- New GitHub PR
- Webhook in GitLab that fetches the patches of the GitHub PR and applies them in a new branch in GitLab.
- Merge branch in GitLab.
But, I have myself gone away from this solution.
What I did ultimately was:
Have a webhook that registers new GItHub PR.
Use python subprocess with the git commands to fetch the pull-request (having github as a remote) and create a branch of it in gitlab. Merge in gitlab. Result: commit-shas are the same on Github and Gitlab and the Github PR gets automatically marked as merged due to the mirroring.