File tree Expand file tree Collapse file tree 6 files changed +13
-6
lines changed Expand file tree Collapse file tree 6 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ You can copy/paste the following snippet into your `.pre-commit-config.yaml` fil
112112 # - Can be configured to replace MOST other hooks
113113 # - Supports repo config file for configuration
114114 # - https://github.com/golangci/golangci-lint
115+ # - Use arg `--hook:path-prefix` to indicate that the repository root
116+ # directory should be passed to the tool (for `*-mod` hooks)
115117 #
116118 - id : golangci-lint
117119 - id : golangci-lint-mod
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22cmd=(golangci-lint run)
3- cmd_pwd_arg =" --path-prefix"
3+ cmd_cwd_arg =" --path-prefix"
44. " $( dirname " ${0} " ) /lib/cmd-mod.bash"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22cmd=(golangci-lint run)
3- cmd_pwd_arg =" --path-prefix"
3+ cmd_cwd_arg =" --path-prefix"
44. " $( dirname " ${0} " ) /lib/cmd-repo-mod.bash"
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ error_code=0
1414#
1515for sub in $( find_module_roots " ${FILES[@]} " | sort -u) ; do
1616 pushd " ${sub} " > /dev/null || exit 1
17- if [ " ${cmd_pwd_arg :- } " ]; then
18- OPTIONS+=(" ${cmd_pwd_arg } =${sub} " )
17+ if [ " ${use_path_prefix :- } " -eq 1 ] && [ " ${cmd_cwd_arg :- }" ]; then
18+ OPTIONS+=(" ${cmd_cwd_arg } =${sub} " )
1919 fi
2020 if [ " ${error_on_output:- } " -eq 1 ]; then
2121 output=$( /usr/bin/env " ${ENV_VARS[@]} " " ${cmd[@]} " " ${OPTIONS[@]} " 2>&1 )
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ error_code=0
1414#
1515for sub in $( find . -name go.mod -not -path ' */vendor/*' -exec dirname " {}" ' ;' | sort -u) ; do
1616 pushd " ${sub} " > /dev/null || exit 1
17- if [ " ${cmd_pwd_arg :- } " ]; then
18- OPTIONS+=(" ${cmd_pwd_arg } =${sub} " )
17+ if [ " ${use_path_prefix :- } " -eq 1 ] && [ " ${cmd_cwd_arg :- }" ]; then
18+ OPTIONS+=(" ${cmd_cwd_arg } =${sub} " )
1919 fi
2020 if [ " ${error_on_output:- } " -eq 1 ]; then
2121 output=$( /usr/bin/env " ${ENV_VARS[@]} " " ${cmd[@]} " " ${OPTIONS[@]} " 2>&1 )
Original file line number Diff line number Diff line change 22
33: " ${use_dot_dot_dot:= 1} "
44: " ${error_on_output:= 0} "
5+ : " ${use_path_prefix:= 0} "
56: " ${ignore_file_pattern_array:= } "
67
78# #
@@ -66,6 +67,10 @@ function parse_file_hook_args {
6667 fi
6768 shift
6869 ;;
70+ --hook:path-prefix)
71+ use_path_prefix=1
72+ shift
73+ ;;
6974 --hook:* )
7075 printf " ERROR: Unknown hook option: '%s'\n" " ${1} " >&2
7176 exit 1
You can’t perform that action at this time.
0 commit comments