blob: 65fdc871c6d381d5db3f439b43766f997b8d60c7 [file] [log] [blame]
Jan Kundrát9b047792019-02-25 18:12:15 +01001- name: Prepare git submodules
2 shell: |
3 set -ex
4
5 jq -r '.projects | .[] | .src_dir ' ~/zuul-env.json | while read PROJECT; do
6 pushd "{{ ansible_user_dir }}/${PROJECT}"
7 # 1) Adjust the origin's URL so that it points to its filesystem location.
8 # This makes relative URLs in submodules work.
9 git config --get remote.origin.url > /dev/null && git config remote.origin.url "{{ ansible_user_dir }}/${PROJECT}" || true
10 # 2) Prepare an alias for each repository, appending the .git suffix.
11 # E.g. Boost uses submodule URLs which end with a .git trailing suffix.
12 # That happens to be handled by many git servers automagically.
13 # Instead of rewriting the submodule URLs within each repo (which would either mark
14 # the repo dirty, or change its hash), use a big hammer and provide these
15 # "compatibility" repository names.
16 # If both a `repo` and `repo.git` already exist, then we're screwed.
17 ln -s $(basename "${PROJECT}") ../$(basename "${PROJECT}").git
18 popd
19 done
20
21 # 3) Update submodules via calling out to git
Jan Kundrát3f5b5f72020-05-13 22:12:20 +020022 cd "{{ zuul_work_dir | default(zuul.project.src_dir) }}"
Jan Kundrát9b047792019-02-25 18:12:15 +010023 git submodule update --init --recursive
24
25 # 4) Undo changes made in step 1
26 jq -r '.projects | .[] | .src_dir ' ~/zuul-env.json | while read PROJECT; do
27 pushd "{{ ansible_user_dir }}/${PROJECT}"
28 git config --get remote.origin.url > /dev/null && git config remote.origin.url file:///dev/null || true
29 popd
30 done