2021-02-18 20:05:43 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
message_file=.git/COMMIT_EDITMSG
|
|
|
|
|
|
|
|
get_git_root() {
|
|
|
|
git rev-parse --show-toplevel
|
|
|
|
}
|
|
|
|
|
|
|
|
write_msg() {
|
|
|
|
echo "$@" >> "${message_file}"
|
|
|
|
}
|
|
|
|
|
|
|
|
git_root="$(get_git_root)"
|
|
|
|
cd "${git_root}"
|
|
|
|
rm -f "${message_file}"
|
|
|
|
write_msg "Auto-update submodules"
|
|
|
|
write_msg ""
|
|
|
|
|
|
|
|
cat ci/update-submodules.manifest | while read path branch; do
|
|
|
|
cd "${git_root}/${path}"
|
|
|
|
test "${git_root}" != "$(get_git_root)"
|
2021-08-11 19:36:01 -06:00
|
|
|
git fetch origin "${branch}:${branch}"
|
2021-02-18 20:05:43 -07:00
|
|
|
git checkout "${branch}"
|
2021-08-11 20:08:25 -06:00
|
|
|
git branch --set-upstream-to="origin/${branch}" "${branch}"
|
2021-02-18 21:22:37 -07:00
|
|
|
git pull --ff-only
|
2021-02-18 20:05:43 -07:00
|
|
|
cd "${git_root}"
|
|
|
|
if ! git diff --quiet --ignore-submodules=dirty -- "${path}"; then
|
|
|
|
git add "${path}"
|
|
|
|
write_msg "${path}: ${branch}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! git diff --exit-code --cached; then
|
|
|
|
git commit --file "${message_file}" --no-edit
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|