From: bochard Date: Sun, 6 Jul 2025 04:30:39 +0000 (+0800) Subject: NOW WITH COLORS! X-Git-Url: https://git.bochard.net/?a=commitdiff_plain;h=81dc1fa4dc79db7892a3e1591a36700073816a50;p=mysite.git NOW WITH COLORS! --- diff --git a/sync-works.sh b/sync-works.sh index c49501c..385fd31 100755 --- a/sync-works.sh +++ b/sync-works.sh @@ -1,8 +1,14 @@ #!/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 @@ -10,27 +16,31 @@ 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