11#! /bin/bash
22
3- # Bumps Chromium manifest if changes detected + git commit/push
3+ # Bumps Chromium manifest if changes detected + git commit/push if --no-<commit|push> not passed
44
55shopt -s nocasematch # enable case-insensitive matching (to flexibly check commit msg for bumps)
66
@@ -12,6 +12,13 @@ BY="\033[1;33m" # bright yellow
1212BG=" \033[1;92m" # bright green
1313BW=" \033[1;97m" # bright white
1414
15+ # Parse ARGS
16+ for arg in " $@ " ; do case " $arg " in
17+ --no-commit) no_commit=true ;;
18+ --no-push) no_push=true ;;
19+ * ) echo -e " ${BR} Invalid argument: $arg .${NC} " && exit 1 ;;
20+ esac ; done
21+
1522# Init manifest PATH
1623MANIFEST_PATH=" chromium/extension/manifest.json"
1724
@@ -46,18 +53,24 @@ echo -e "Updated: ${BW}v${old_ver}${NC} → ${BG}v${new_ver}${NC}\n"
4653(( bumped_cnt++ ))
4754if (( $bumped_cnt == 0 )) ; then echo -e " ${BW} Completed. No manifests bumped.${NC} " ; exit 0 ; fi
4855
49- # PULL latest changes
50- echo -e " ${BY} Pulling latest changes from remote to sync local repository...${NC} \n"
51- git pull || (echo -e " ${BR} Merge failed, please resolve conflicts!${NC} " && exit 1)
52- echo ' '
53-
5456# ADD/COMMIT/PUSH bump(s)
55- plural_suffix=$(( ( $bumped_cnt > 1 )) && echo " s" )
56- echo -e " ${BG}${bumped_cnt} manifest${plural_suffix} bumped!\n${NC} "
57- echo -e " ${BY} Committing bump${plural_suffix} to Git...\n${NC} "
58- COMMIT_MSG=" Bumped \` version\` "
59- unique_versions=($( printf " %s\n" " ${new_versions[@]} " | sort -u) )
60- if (( ${# unique_versions[@]} == 1 )) ; then COMMIT_MSG+=" to \` ${unique_versions[0]} \` " ; fi
61- git add ./** /manifest.json && git commit -n -m " $COMMIT_MSG "
62- git push
63- echo -e " \n${BG} Success! ${bumped_cnt} manifest${plural_suffix} updated/committed/pushed to GitHub${NC} "
57+ if [[ " $no_commit " != true ]] ; then
58+ plural_suffix=$(( ( $bumped_cnt > 1 )) && echo " s" )
59+ echo -e " ${BG}${bumped_cnt} manifest${plural_suffix} bumped!\n${NC} "
60+ echo -e " ${BY} Committing bump${plural_suffix} to Git...\n${NC} "
61+ COMMIT_MSG=" Bumped \` version\` "
62+ unique_versions=($( printf " %s\n" " ${new_versions[@]} " | sort -u) )
63+ if (( ${# unique_versions[@]} == 1 )) ; then COMMIT_MSG+=" to \` ${unique_versions[0]} \` " ; fi
64+ git add ./** /manifest.json && git commit -n -m " $COMMIT_MSG "
65+ if [[ " $no_push " != true ]] ; then
66+ echo -e " ${BY} Pulling latest changes from remote to sync local repository...${NC} \n"
67+ git pull || (echo -e " ${BR} Merge failed, please resolve conflicts!${NC} " && exit 1)
68+ echo -e " ${BY} Pushing bump${plural_suffix} to Git...\n${NC} "
69+ git push
70+ fi
71+ fi
72+
73+ # FINAL log
74+ git_action=" updated" $( [[ " $no_commit " != true ]] && echo -n " /committed" ) $(
75+ [[ " $no_push " != true ]] && echo -n " /pushed" )
76+ echo -e " \n${BG} Success! ${bumped_cnt} manifest${plural_suffix} ${git_action} to GitHub${NC} "
0 commit comments