mirror of
https://github.com/andwati/dotfiles.git
synced 2026-10-18 02:52:52 +00:00
Update repo_sync.sh
added colors added progress indicators
This commit is contained in:
+27
-3
@@ -3,29 +3,53 @@
|
|||||||
GITHUB_USERNAME="andwati"
|
GITHUB_USERNAME="andwati"
|
||||||
DESTINATION_FOLDER=~/cloned
|
DESTINATION_FOLDER=~/cloned
|
||||||
|
|
||||||
|
GREEN="\e[32m"
|
||||||
|
BLUE="\e[34m"
|
||||||
|
RED="\e[31m"
|
||||||
|
RESET="\e[0m"
|
||||||
|
|
||||||
clone_repositories() {
|
clone_repositories() {
|
||||||
local parent_dir=$1
|
local parent_dir=$1
|
||||||
local repo_name=$2
|
local repo_name=$2
|
||||||
|
|
||||||
gh repo clone "$GITHUB_USERNAME/$repo_name" "$parent_dir/$repo_name"
|
|
||||||
|
|
||||||
|
echo -e "${BLUE}Cloning repository: $repo_name${RESET}"
|
||||||
|
if gh repo clone "$GITHUB_USERNAME/$repo_name" "$parent_dir/$repo_name"; then
|
||||||
|
echo -e "${GREEN}Successfully cloned: $repo_name${RESET}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Failed to clone: $repo_name${RESET}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
cd "$parent_dir/$repo_name" || exit
|
cd "$parent_dir/$repo_name" || exit
|
||||||
|
|
||||||
|
|
||||||
if [ -f ".gitmodules" ]; then
|
if [ -f ".gitmodules" ]; then
|
||||||
|
echo -e "${BLUE}Initializing and updating submodules for: $repo_name${RESET}"
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update
|
git submodule update
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|
||||||
mkdir -p "$DESTINATION_FOLDER"
|
mkdir -p "$DESTINATION_FOLDER"
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "${BLUE}Fetching repositories for user: $GITHUB_USERNAME${RESET}"
|
||||||
repos=$(gh repo list "$GITHUB_USERNAME" --visibility all --limit 100 --json name -q '.[].name')
|
repos=$(gh repo list "$GITHUB_USERNAME" --visibility all --limit 100 --json name -q '.[].name')
|
||||||
|
|
||||||
|
|
||||||
|
total_repos=$(echo "$repos" | wc -w)
|
||||||
|
count=0
|
||||||
|
|
||||||
for repo in $repos; do
|
for repo in $repos; do
|
||||||
echo "Cloning repository: $repo"
|
count=$((count + 1))
|
||||||
|
echo -e "${BLUE}Progress: [$count/$total_repos]${RESET}"
|
||||||
clone_repositories "$DESTINATION_FOLDER" "$repo"
|
clone_repositories "$DESTINATION_FOLDER" "$repo"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo -e "${GREEN}Cloning complete! ${RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|||||||
Reference in New Issue
Block a user