File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ append_manual_module_license() {
5858 local expected_sha256=" $5 "
5959 local out=" $6 "
6060
61- local module_info version dir selected_sha256
61+ local module_info version dir downloaded_dir selected_sha256
6262
6363 if ! module_info=" $( cd " $repo_root " && go list -m -f ' {{.Version}} {{.Dir}}' " $module " 2> /dev/null) " ; then
6464 return 0
7575 return 1
7676 fi
7777
78+ if [[ ! -f " $dir /$license_file " ]]; then
79+ # go list -m can return an empty Dir in clean module caches when the
80+ # package is ignored above. Download the pinned module before auditing.
81+ if downloaded_dir=" $( cd " $repo_root " && go mod download -json " $module @$expected_version " | awk -F ' "' ' $2 == "Dir" { print $4; exit }' ) " && [[ -n " $downloaded_dir " ]]; then
82+ dir=" $downloaded_dir "
83+ fi
84+ fi
85+
7886 if [[ ! -f " $dir /$license_file " ]]; then
7987 cat >&2 << EOF
8088Manual license audit for $module expected $license_file , but it was not found in $dir .
You can’t perform that action at this time.
0 commit comments