Add git-sync command to fetch from a list of repos

This commit is contained in:
2023-04-20 12:45:38 +01:00
parent d5ae3dbfc8
commit 7fb360690d
2 changed files with 25 additions and 20 deletions

23
git-sync Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env zsh
autoload -U colors && colors
git_sync=${GIT_SYNC:-~/.config/git-sync}
if [ ! -f "$git_sync" ]; then
echo "$fg[yellow]warning:${reset_color} sync list does not exist: $git_sync"
exit 0
fi
local repos=($(cat $git_sync))
if [ ${#repos[@]} = 0 ]; then
echo "$fg[yellow]warning:${reset_color} sync list is empty: $git_sync"
exit 0
fi
for repo in $repos; do
print -P "$fg[cyan]synchronizing: $repo${reset_color}"
repo="${repo/#\~/$HOME}"
git -C "$repo" fetch
done