blob: c6d26df9355a760a9aab8e5c78f5feff034c9999 [file] [log] [blame]
- name: Prepare git submodules
shell: |
set -ex
jq -r '.projects | .[] | .src_dir ' ~/zuul-env.json | while read PROJECT; do
pushd "{{ ansible_user_dir }}/${PROJECT}"
# 1) Adjust the origin's URL so that it points to its filesystem location.
# This makes relative URLs in submodules work.
git config --get remote.origin.url > /dev/null && git config remote.origin.url "{{ ansible_user_dir }}/${PROJECT}" || true
# 2) Prepare an alias for each repository, appending the .git suffix.
# E.g. Boost uses submodule URLs which end with a .git trailing suffix.
# That happens to be handled by many git servers automagically.
# Instead of rewriting the submodule URLs within each repo (which would either mark
# the repo dirty, or change its hash), use a big hammer and provide these
# "compatibility" repository names.
# If both a `repo` and `repo.git` already exist, then we're screwed.
ln -s $(basename "${PROJECT}") ../$(basename "${PROJECT}").git
popd
done
# 3) Update submodules via calling out to git
IFS=':' read -ra SUBMODULES_TO_EXPAND <<< "{{ git_submodule_dirs | default(zuul.project.src_dir) }}"
for A_REPO in "${SUBMODULES_TO_EXPAND[@]}"; do
pushd "${A_REPO}"
git submodule update --init --recursive
popd
done
# 4) Undo changes made in step 1
jq -r '.projects | .[] | .src_dir ' ~/zuul-env.json | while read PROJECT; do
pushd "{{ ansible_user_dir }}/${PROJECT}"
git config --get remote.origin.url > /dev/null && git config remote.origin.url file:///dev/null || true
popd
done