blob: 100de133aafd6be2ba6e44b93cc46bbf27dbadd7 [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
22 cd "$(jq -r '.project.src_dir' ~/zuul-env.json)"
23 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