Files
nix/lib/scripts/update.sh
Nikolaos Karaolidis 7fa058293b Update update script
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-02-16 15:36:30 +00:00

41 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
paths=$(git config --file .gitmodules --name-only --get-regexp path | while read -r line; do
path=$(git config --file .gitmodules --get "${line}")
url=$(git config --file .gitmodules --get "${line%.*}.url")
if [[ ${url} == *"karaolidis"* ]]; then
echo "${path}"
fi
done)
for path in ${paths}; do
echo "Processing submodule: ${path}"
cd "${path}" || exit
default_branch=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
git checkout "${default_branch}"
git fetch upstream
git merge "upstream/${default_branch}"
branches=$(git for-each-ref --format='%(refname:short)' refs/heads/ | grep -v "^${default_branch}$")
for branch in ${branches}; do
git checkout "${branch}"
git rebase "${default_branch}"
done
git checkout integration
git push origin --all --force-with-lease
git push origin --tags --force-with-lease
cd - > /dev/null || exit
done
echo "All submodules updated successfully."
nix flake update