Allow dot in :submodule route
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA
What does this MR do and why?
Closes: submodule contains `.` will not be updated (#25783 - closed)
The GitLab API allows updating the commit a submodule references. However if the submodule path has a dot (.) in it the request fails with a 404.
A previous MR !24410 (closed) attempted this fix but was eventually closed after remaining open for several years. Reading the comments there appears to have been an open question that was never answered !24410 (comment 481501103) regarding the root cause being contained in Gitaly... my findings (and testing) did not reach the same conclusion. After applying the change contained in this MR I was able to successfully make an API call to the PUT /projects/:id/repository/submodules/:submodule
and receive the expected response. Its entirely possible that whatever underlying issue in Gitaly that may have existed at the time of the previous MR has been resolved.
How to set up and validate locally
- Create a new group (e.g.
test-group
) - Create a new project (e.g.
test-submodule
) within the group created in step1
- Create a new project (e.g.
test-project
) within the group created in step1
- Clone the
test-submodule
project,git submodule add git@gitlab.com:test-group/test-submodule.git
- Change into
test-submodule
directory - Enter the command
git submodule add git@gitlab.com:test-group/test-project.git .my-submodule
- Commit & push changes to remote
- Generate an access token (give
api
scope) - From shell enter command
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/test-group%2Ftest-project/repository/submodules/.my-submodule" \ --data "branch=main&commit_sha=<commit SHA goes here>&commit_message=Update submodule reference"
- Observe a successful response