Skip to content

Commit 168b65d

Browse files
committed
Download manually audited license modules
1 parent e342cc5 commit 168b65d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

hack/update-third-party-licenses.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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
@@ -75,6 +75,14 @@ EOF
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
8088
Manual license audit for $module expected $license_file, but it was not found in $dir.

0 commit comments

Comments
 (0)