File tree Expand file tree Collapse file tree 7 files changed +22
-15
lines changed
Expand file tree Collapse file tree 7 files changed +22
-15
lines changed Original file line number Diff line number Diff line change 3636 env :
3737 # NOTE: use env to pass the output in order to avoid possible injection attacks
3838 FILES : " ${{ steps.files.outputs.added_modified }}"
39+ - name : Shellcheck
40+ run : shellcheck --severity=error bin/* ./*.sh
3941 - name : Lint and format Python with Ruff
4042 uses : astral-sh/ruff-action@v2
4143
Original file line number Diff line number Diff line change 3939 REMOTE=origin
4040fi
4141
42- test -z $BRANCH && echo " branch argument required." 1>&2 && exit 1
42+ test -z " $BRANCH " && echo " branch argument required." 1>&2 && exit 1
4343
4444if [[ -n $REMOTE ]]
4545then
Original file line number Diff line number Diff line change 6161 # clone forked repo into current dir
6262 git clone " ${remote_prefix}${user} /${project} .git" " $project "
6363 # add reference to origin fork so can merge in upstream changes
64- cd " $project "
64+ cd " $project " || exit
6565 git remote add upstream " ${remote_prefix}${owner} /${project} .git"
6666 git fetch upstream
6767fi
Original file line number Diff line number Diff line change 3131 esac
3232done
3333
34- cd " $( git-root) " # cd for git blame
34+ cd " $( git-root) " || exit # cd for git blame
3535MERGED_LOG=$( git_extra_mktemp)
3636if [[ $EMAIL == ' -e' ]]
3737then
@@ -44,9 +44,11 @@ for file in $(git diff --name-only "$@")
4444do
4545 test -n " $DEBUG " && echo " git blame $file "
4646 # $1 - since $2 - until
47+ # shellcheck disable=SC2086
4748 git blame $NOT_WHITESPACE --line-porcelain " $1 " -- " $file " 2> /dev/null |
4849 LC_ALL=C sed -n " $PATTERN " | sort | uniq -c | LC_ALL=C sed ' s/^\(.\)/- \1/' >> " $MERGED_LOG "
4950 # if $2 not given, use current commit as "until"
51+ # shellcheck disable=SC2086
5052 git blame $NOT_WHITESPACE --line-porcelain " ${2-@ } " -- " $file " 2> /dev/null |
5153 LC_ALL=C sed -n " $PATTERN " | sort | uniq -c | LC_ALL=C sed ' s/^\(.\)/+ \1/' >> " $MERGED_LOG "
5254done
7173 printf("%d %s\n", contributors[people], people)
7274 }
7375 }
74- }' $MERGED_LOG | sort -nr | # only gawk supports built-in sort function
76+ }' " $MERGED_LOG " | sort -nr | # only gawk supports built-in sort function
7577while read -r line
7678do
7779 people=${line#* }
103105 do
104106 printf " -"
105107 done
106- printf " (%s)" $num
108+ printf " (%s)" " $num "
107109 else
108110 for (( i = 0 ; i > num; i-- ))
109111 do
Original file line number Diff line number Diff line change 99 file=" $file " ' ' " $i "
1010 shift
1111done
12- test -n " $* " && range=" $* "
12+ test -n " $* " && range=( " $@ " )
1313
1414test -z " $file " && echo " file required." 1>&2 && exit 1
15- if [ -z " $range " ]
15+ if [ -z " ${ range[*]} " ]
1616then
1717 git filter-branch -f --index-filter " git rm -r --cached " " $file " " --ignore-unmatch" \
1818 --prune-empty --tag-name-filter cat -- --all
1919else
20- # don't quote $range so that we can forward multiple rev-list arguments
20+ # $range is an array so that we can forward multiple rev-list arguments
2121 git filter-branch -f --index-filter " git rm -r --cached " " $file " " --ignore-unmatch" \
22- --prune-empty --tag-name-filter cat -- $ range
22+ --prune-empty --tag-name-filter cat -- " ${ range[@]} "
2323fi
Original file line number Diff line number Diff line change @@ -44,8 +44,10 @@ while true; do
4444 esac
4545
4646 if [[ $cmd == ! * ]]; then
47+ # shellcheck disable=SC2086
4748 eval ${cmd: 1}
4849 elif [[ $cmd == git* ]]; then
50+ # shellcheck disable=SC2086
4951 eval $cmd
5052 else
5153 eval git " $cmd "
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ function php_lint()
5959
6060function _dos2unix()
6161{
62- command -v dos2unix > /dev/null && dos2unix $@
62+ command -v dos2unix > /dev/null && dos2unix " $@ "
6363 return 0
6464}
6565
@@ -68,8 +68,8 @@ function _sanitize()
6868 git config --get-all extras.scp.sanitize | while read -r i
6969 do
7070 case $i in
71- php_lint) php_lint $@ ;; # git config --global --add extras.scp.sanitize php_lint
72- dos2unix) _dos2unix $@ ;; # git config --global --add extras.scp.sanitize dos2unix
71+ php_lint) php_lint " $@ " ;; # git config --global --add extras.scp.sanitize php_lint
72+ dos2unix) _dos2unix " $@ " ;; # git config --global --add extras.scp.sanitize dos2unix
7373 esac
7474 done
7575 return $?
@@ -107,6 +107,7 @@ function scp_and_stage
107107 if [ -n " $list " ]
108108 then
109109 local _TMP=${0/// }
110+ # shellcheck disable=SC2086
110111 echo " $list " > " $_TMP " &&
111112 _sanitize $list &&
112113 _info " Pushing to $remote ($( git config " remote.$remote .url" ) )" &&
@@ -131,7 +132,7 @@ function reverse_scp()
131132 shift
132133
133134 local _TMP=${0/// }
134- echo $@ > " $_TMP " &&
135+ echo " $@ " > " $_TMP " &&
135136 rsync -rlDv --files-from=" $_TMP " " $( git config " remote.$remote .url" ) /" ./ &&
136137 rm " $_TMP "
137138}
@@ -173,8 +174,8 @@ case $(basename "$0") in
173174 git-scp)
174175 case $1 in
175176 ' ' |-h|' ?' |help|--help) shift ; _test_git_scp; _usage " $@ " ;;
176- * ) scp_and_stage $@ ;;
177+ * ) scp_and_stage " $@ " ;;
177178 esac
178179 ;;
179- git-rscp) reverse_scp $@ ;;
180+ git-rscp) reverse_scp " $@ " ;;
180181esac
You can’t perform that action at this time.
0 commit comments