From 4f5579b634f2a459d1a2fa8bdebc668928a8e501 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 8 Feb 2021 11:58:30 +0100 Subject: add LIMIT and LIMIT_TO to limit repo syncing to specific repos --- github_sync.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'github_sync.sh') diff --git a/github_sync.sh b/github_sync.sh index f33374f..61bdd45 100755 --- a/github_sync.sh +++ b/github_sync.sh @@ -15,6 +15,8 @@ # TOKEN Password or Token # REPO_DIR Directory on the filesystem # PRIVATE Treat repositories as private (true/false) +# LIMIT Limit syncing to repos specified in LIMIT_TO (true/false) +# LIMIT_TO Array of repos to limit syncing to ARGV=($@) ARGC=${#ARGV[@]} @@ -100,6 +102,17 @@ TO_CREATE=( $(comm -13 <(printf "%s\n" "${!GH_REPOS[@]}" | sort) \ TO_PUSH=( $(comm -12 <(printf "%s\n" "${!GH_REPOS[@]}" | sort) \ <(printf "%s\n" "${LOCAL_REPOS[@]}" | sort) ) ) +if [ "$LIMIT" = "true" -a "${#LIMIT_TO[@]}" -gt 0 ]; then + TO_CLONE=( $(comm -12 <(printf "%s\n" "${LIMIT_TO[@]}" | sort) \ + <(printf "%s\n" "${TO_CLONE[@]}" | sort) ) ) + + TO_CREATE=( $(comm -12 <(printf "%s\n" "${LIMIT_TO[@]}" | sort) \ + <(printf "%s\n" "${TO_CREATE[@]}" | sort) ) ) + + TO_PUSH=( $(comm -12 <(printf "%s\n" "${LIMIT_TO[@]}" | sort) \ + <(printf "%s\n" "${TO_PUSH[@]}" | sort) ) ) +fi + echo TO CLONE printf "%s\n" "${TO_CLONE[@]}" echo -- cgit v1.2.3