For MRs created from a branch on a fork, allow setting commit status by targeting the original project
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
Today, for MRs where the source is a branch in the forked repo, when using external CI, we must POST a commit status by targeting the fork.
We could allow users to submit commit statuses by targeting the original(fork source) repo.
Reproduce
Right now if I:
- Create a public project
- Fork the public project
- Create a branch with changes in the fork
- Create a merge request from the branch
- Attempt to update a commit on the branch
This fails since the commit isn't in the fork source repo. Example:
Targeting the fork source from (allison.browne/16491):
~
▶ curl --request POST --header "PRIVATE-TOKEN: <token>" "https://gitlab.com/api/v4/projects/allison.browne%2F16491/statuses/6bc97fa42c553c7ee9ac323dd1d637b763d1e861?state=success"
{"message":"404 References for commit Not Found"}%
Today we must submit commit status by target the fork repo instead.
~
▶ curl --request POST --header "PRIVATE-TOKEN: <token>" "https://gitlab.com/api/v4/projects/allison.browne%2F16491-fork/statuses/6bc97fa42c553c7ee9ac323dd1d637b763d1e861?state=success"
{"id":3041220365,"sha":"6bc97fa42c553c7ee9ac323dd1d637b763d1e861","ref":"allison.browne-main-patch-50581","status":"success","name":"default","target_url":null,"description":null,"created_at":"2022-09-16T16:02:42.770Z","started_at":null,"finished_at":"2022-09-16T16:02:42.768Z","allow_failure":false,"coverage":null,"author":{"id":4626651,"username":"allison.browne","name":"Allison Browne","state":"active","avatar_url":"https://secure.gravatar.com/avatar/4bc33904c3bd3f2dce3db4e5af4ad1ae?s=80\u0026d=identicon","web_url":"https://gitlab.com/allison.browne"}}%
Potential solution
We already create the merge request ref in the fork source project when commits are pushed with an existing MR opened for the branch. We need to ensure we can use this ref to find the commits.
Edited by 🤖 GitLab Bot 🤖