Skip to content

Add support for selective git submodule paths inclusion/exclusion

Georgi N. Georgiev requested to merge feat-submodules-path into master

What does this MR do?

Adds support for GIT_SUBMODULE_PATHS allowing to include/exclude submodules when cloning your repo.

Based on !1838 (closed)

Why was this MR needed?

Repos with many/big submodules might not need them every time.

What's the best way to test this MR?

In your playground repo add the gitlab-test repo as a submodule:

git submodule add https://gitlab.com/gitlab-org/ci-cd/tests/gitlab-test

.gitlab-ci.yaml:

ls:
    variables:
        GIT_SUBMODULE_STRATEGY: normal
    script:
        - echo $GIT_SUBMODULE_PATHS
        - ls gitlab-test | wc -l

Run jobs with:

  • GIT_SUBMODULE_PATHS: (empty):
 $ echo $GIT_SUBMODULE_PATHS
 $ ls gitlab-test | wc -l
 2
 Job succeeded
  • GIT_SUBMODULE_PATHS:gitlab-test:
 $ echo $GIT_SUBMODULE_PATHS
 gitlab-test
 $ ls gitlab-test | wc -l
 2
 Job succeeded
  • GIT_SUBMODULE_PATHS::(exclude)gitlab-test:
 $ echo $GIT_SUBMODULE_PATHS
 :(exclude)gitlab-test
 $ ls gitlab-test | wc -l
 0
 Job succeeded

What are the relevant issue numbers?

gitlab!25475 (closed)

Closes #26495 (closed)

Edited by Georgi N. Georgiev

Merge request reports