File tree 6 files changed +13
-6
lines changed
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
112
112
# - Can be configured to replace MOST other hooks
113
113
# - Supports repo config file for configuration
114
114
# - 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)
115
117
#
116
118
- id : golangci-lint
117
119
- id : golangci-lint-mod
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
cmd=(golangci-lint run)
3
- cmd_pwd_arg =" --path-prefix"
3
+ cmd_cwd_arg =" --path-prefix"
4
4
. " $( dirname " ${0} " ) /lib/cmd-mod.bash"
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
cmd=(golangci-lint run)
3
- cmd_pwd_arg =" --path-prefix"
3
+ cmd_cwd_arg =" --path-prefix"
4
4
. " $( dirname " ${0} " ) /lib/cmd-repo-mod.bash"
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ error_code=0
14
14
#
15
15
for sub in $( find_module_roots " ${FILES[@]} " | sort -u) ; do
16
16
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} " )
19
19
fi
20
20
if [ " ${error_on_output:- } " -eq 1 ]; then
21
21
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
14
14
#
15
15
for sub in $( find . -name go.mod -not -path ' */vendor/*' -exec dirname " {}" ' ;' | sort -u) ; do
16
16
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} " )
19
19
fi
20
20
if [ " ${error_on_output:- } " -eq 1 ]; then
21
21
output=$( /usr/bin/env " ${ENV_VARS[@]} " " ${cmd[@]} " " ${OPTIONS[@]} " 2>&1 )
Original file line number Diff line number Diff line change 2
2
3
3
: " ${use_dot_dot_dot:= 1} "
4
4
: " ${error_on_output:= 0} "
5
+ : " ${use_path_prefix:= 0} "
5
6
: " ${ignore_file_pattern_array:= } "
6
7
7
8
# #
@@ -66,6 +67,10 @@ function parse_file_hook_args {
66
67
fi
67
68
shift
68
69
;;
70
+ --hook:path-prefix)
71
+ use_path_prefix=1
72
+ shift
73
+ ;;
69
74
--hook:* )
70
75
printf " ERROR: Unknown hook option: '%s'\n" " ${1} " >&2
71
76
exit 1
You can’t perform that action at this time.
0 commit comments