2023-06-09 17:22:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
subdirs_path=$(dirname -- "$(realpath -- "$0")")
|
|
|
|
cd "$subdirs_path"
|
|
|
|
|
|
|
|
declare -A repo_names=(
|
|
|
|
[c++utilities]=cpp-utilities
|
|
|
|
[qtutilities]=
|
|
|
|
[qtforkawesome]=
|
|
|
|
[syncthingtray]=
|
|
|
|
[tagparser]=
|
|
|
|
[tageditor]=
|
|
|
|
[passwordfile]=
|
|
|
|
[passwordmanager]=
|
|
|
|
[videodownloader]=
|
|
|
|
[reflective-rapidjson]=
|
|
|
|
[dbus-soundrecorder]=
|
|
|
|
[geocoordinatecalculator]=
|
2023-06-10 23:40:51 +02:00
|
|
|
[auto-makepkg]=arch-repo-manager
|
2023-06-11 01:03:30 +02:00
|
|
|
[subdirs]=
|
2023-06-09 17:22:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# ensure a clone of all repositories exists
|
|
|
|
for dir in "${!repo_names[@]}"; do
|
|
|
|
[[ -d ../$dir/.git ]] && continue
|
|
|
|
echo "==> Cloning $dir"
|
|
|
|
repo=${repo_names[$dir]:-$dir}
|
2023-06-09 18:01:09 +02:00
|
|
|
git -C .. clone -c core.symlinks=true "git@github.com:Martchus/$repo.git" "$dir"
|
2023-06-09 17:22:46 +02:00
|
|
|
done
|
|
|
|
|
2023-06-11 01:03:30 +02:00
|
|
|
# ensure the fallback repo is added
|
|
|
|
for dir in "${!repo_names[@]}"; do
|
|
|
|
repo=${repo_names[$dir]:-$dir}
|
|
|
|
if ! git -C "../$dir" remote show gitea &> /dev/null ; then
|
|
|
|
echo "==> Adding fallback remote for $dir"
|
|
|
|
git -C "../$dir" remote add gitea "gitea@martchus.no-ip.biz:Martchus/$repo.git"
|
|
|
|
fi
|
|
|
|
if ! git -C "../$dir" remote show all &> /dev/null ; then
|
|
|
|
echo "==> Configuring 'all' remote for $dir"
|
|
|
|
git -C "../$dir" remote add all "git@github.com:Martchus/$repo.git"
|
|
|
|
git -C "../$dir" remote set-url --add --push all "git@github.com:Martchus/$repo.git"
|
|
|
|
git -C "../$dir" remote set-url --add --push all "gitea@martchus.no-ip.biz:Martchus/$repo.git"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2023-06-09 17:22:46 +02:00
|
|
|
# ensure all repositories are up-to-date
|
|
|
|
for dir in ../* ; do
|
|
|
|
[[ -d $dir/.git ]] || continue
|
|
|
|
echo "==> Updating $dir"
|
|
|
|
git -C "$dir" remote update
|
|
|
|
branch_name=$(git -C "$dir" symbolic-ref -q HEAD)
|
|
|
|
branch_name=${branch_name##refs/heads/}
|
|
|
|
branch_name=${branch_name:-DETACHED}
|
|
|
|
if output=$(git -C "$dir" status --porcelain) && [[ -z $output ]] && [[ $branch_name == DETACHED || $branch_name == master ]]; then
|
|
|
|
git -C "$dir" reset --hard origin/master
|
|
|
|
fi
|
|
|
|
done
|