Skip to content

Commit 0e1311a

Browse files
committed
Added --no-<push|commit> options + push status echo ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/perplexity-omnibox]
1 parent af29004 commit 0e1311a

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"lint:fix-all": "eslint . --fix",
2525
"bump": "bash utils/bump.sh",
2626
"bump:ext": "bash utils/bump.sh",
27+
"bump:ext-nc": "bash utils/bump.sh --no-commit",
28+
"bump:ext-np": "bash utils/bump.sh --no-push",
2729
"bump:extension": "bash utils/bump.sh",
2830
"bump:extensions": "bash utils/bump.sh",
2931
"bump:manifest": "bash utils/bump.sh",

utils/bump.sh

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

55
shopt -s nocasematch # enable case-insensitive matching (to flexibly check commit msg for bumps)
66

@@ -12,6 +12,13 @@ BY="\033[1;33m" # bright yellow
1212
BG="\033[1;92m" # bright green
1313
BW="\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
1623
MANIFEST_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++))
4754
if (( $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

Comments
 (0)