#!/bin/bash
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[0;33m'
+BLUE='\033[0;34m'
+NC='\033[0m'
+
declare -A works
-echo "Reading works-list.txt file...";
+echo -e "${BLUE}Reading works-list.txt file...${NC}";
while IFS=' ' read -r name url || [ -n "$name" ]; do
works[$name]="$url"
done < works-list.txt
worksBase='works'
mkdir -p "$worksBase"
-echo "Cloning or updating repos in $worksBase..."
+echo -e "${BLUE}Cloning or updating repos in $worksBase...${NC}"
for work in "${!works[@]}"; do
destPath="$worksBase/$work"
if [ ! -d "$destPath" ]; then
- echo "Cloning $work to $worksBase..."
+ echo -e "${BLUE}Cloning $work to $worksBase...${NC}"
git clone "${works[$work]}" "$destPath"
- echo "$work cloned successfully."
+ echo -e "${GREEN}$work cloned successfully.${NC}"
else
- echo "$work already exists. Fetching latest changes..."
+ echo -e "${BLUE}$work already exists. Fetching latest changes...${NC}"
branch=$(git -C "$destPath" rev-parse --abbrev-ref HEAD)
git -C "$destPath" fetch origin
git -C "$destPath" reset --hard "origin/$branch"
- echo "$work updated to latest commit on $branch."
+ echo -e "${GREEN}$work updated to latest commit on $branch.${NC}"
fi
done
-echo "Staging changes in $worksBase..."
+echo -e "${BLUE}Staging changes in $worksBase...${NC}"
git add "$worksBase/"
-echo "Committing changes..."
-git commit -m "Updated cloned repos in $worksBase." || echo "Nothing to commit."
+echo -e "${BLUE}Committing changes...${NC}"
+if git commit -m "Updated cloned repos in $worksBase."; then
+ echo -e "${GREEN}Changes committed.${NC}"
+else
+ echo -e "${RED}Nothing to commit.${NC}"
+fi
-echo "done."
\ No newline at end of file
+echo -e "${GREEN}done.${NC}"
\ No newline at end of file