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