Skip to content

Allow dot in :submodule route

Sac Valley Tech requested to merge sac-valley-tech/forks/gitlab:master into master
  • 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

  1. Create a new group (e.g. test-group)
  2. Create a new project (e.g. test-submodule) within the group created in step 1
  3. Create a new project (e.g. test-project) within the group created in step 1
  4. Clone the test-submodule project, git submodule add git@gitlab.com:test-group/test-submodule.git
  5. Change into test-submodule directory
  6. Enter the command git submodule add git@gitlab.com:test-group/test-project.git .my-submodule
  7. Commit & push changes to remote
  8. Generate an access token (give api scope)
  9. 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"
  10. Observe a successful response
Edited by Ash McKenzie

Merge request reports

Loading