]>
git.r.bdr.sh - rbdr/dotfiles/blob - zsh/functions/sync-repos.zsh
3 # Function to check and process git repositories
6 local relative_path
="${repo_path#$PWD/}"
10 print
-n "${relative_path}: "
12 local remotes
=($(git remote))
14 if [[ ${#remotes[@]} -eq 0 ]]; then
15 print
-P "%F{red}NO REMOTES%f"
20 # Check for required remotes
23 local existing_remotes
=""
25 for remote
in $remotes; do
26 [[ $remote == "origin" ]] && has_origin
=1
27 [[ $remote == "conchos" ]] && has_conchos
=1
28 existing_remotes
="${existing_remotes:+$existing_remotes,}$remote"
31 # If missing any required remote
32 if [[ $has_origin -eq 0 || $has_conchos -eq 0 ]]; then
33 print
-P "%F{yellow}MISSING REMOTES ${existing_remotes}%f"
38 # Try pushing to both remotes
39 if git push
--all origin
>/dev
/null
2>&1 && git push
--all conchos
>/dev
/null
2>&1; then
40 print
-P "%F{green}UPDATED%f"
42 print
-P "%F{red}OUTDATED%f"
48 local start_dir
="${1:-.}"
49 fd
-H -t d
'^\.git$' -x echo {} | sort | sed 's/\/\.git$//' | rg
-v "${SYNC_REPOS_IGNORE}" | while read -r repo_path
; do
50 sync
-repo "$repo_path"