Skip to content

submodule contains `.` will not be updated

Summary

submodule path contains '.' like "lib/module/1.2" cannot be updated by the submodule update API which introduced in GitLab 11.5

Steps to reproduce

create a repos which has some submodules like:

[submodule "sub/lib_1"]
        path = sub/lib_1
        url = ../../all_user/exp_sub_submodule
        branch = master
[submodule "sub/lib.1"]
        path = sub/lib.1
        url = ../../all_user/exp_sub_submodule
        branch = master

update two submodule

using:

 curl --request PUT --header "PRIVATE-TOKEN: -p2wxg_ENHKAZbPRYPsw" "http://gitlab.com/api/v4/projects/95/repository/submodules/sub%2Flib_1" --data "branch=master&commit_sha=1caf5b21630e5ed27bdad96479ae69cad6db4760&commit_message=Update submodule reference" 

  curl --request PUT --header "PRIVATE-TOKEN: -p2wxg_ENHKAZbPRYPsw" "http://gitlab.com/api/v4/projects/95/repository/submodules/sub%2Flib.1" --data "branch=master&commit_sha=1caf5b21630e5ed27bdad96479ae69cad6db4760&commit_message=Update submodule reference" 

What is the current bug behavior?

  1. update successful
  2. return {"message":"Invalid submodule path"}

What is the expected correct behavior?

both can be updated successfully

Possible fixes

I have debuged for this issue. It should be parameter parse issue.

for the file lib/api/submodules.rb the submodule parameter should be parsed just like in lib/api/files.rb

so the correct codes are:

    FILE_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(submodule: API::NO_SLASH_URL_PART_REGEX)
    put ":id/repository/submodules/:submodule", requirements: FILE_ENDPOINT_REQUIREMENTS

submoudles.rb

This is the first time which I contributed to the Gitlab. If I have made some mistakes, please let me know

Edited by 🤖 GitLab Bot 🤖