Jan Kundrát | 4552bf4 | 2019-02-13 19:39:43 +0100 | [diff] [blame] | 1 | - hosts: all |
| 2 | tasks: |
Jan Kundrát | 057cb59 | 2019-02-14 17:59:41 +0100 | [diff] [blame^] | 3 | - name: Prepare git submodules |
| 4 | shell: | |
| 5 | set -ex |
Jan Kundrát | 4552bf4 | 2019-02-13 19:39:43 +0100 | [diff] [blame] | 6 | |
Jan Kundrát | 057cb59 | 2019-02-14 17:59:41 +0100 | [diff] [blame^] | 7 | 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át | 4552bf4 | 2019-02-13 19:39:43 +0100 | [diff] [blame] | 22 | |
Jan Kundrát | 057cb59 | 2019-02-14 17:59:41 +0100 | [diff] [blame^] | 23 | # 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át | 4552bf4 | 2019-02-13 19:39:43 +0100 | [diff] [blame] | 26 | |
Jan Kundrát | 057cb59 | 2019-02-14 17:59:41 +0100 | [diff] [blame^] | 27 | # 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 |