From d0fac451e0b2aafed3210fdca25c008a44d5da46 Mon Sep 17 00:00:00 2001 From: Eric Chiang Date: Wed, 22 Nov 2017 09:38:17 -0800 Subject: [PATCH] hack: fix godep license parsing for gopkg.in packages The script incorrectly thinks that `gopkg.in/square/go-jose.v2/cipher` doesn't have a license because it parses `gopkg.in/square` as the root of the repo, even though `gopkg.in/square/go-jose.v2` is the root. Add special handling for gopkg.in packages by grep'ing for the version that gopkg.in appends to the package name. --- hack/update-godep-licenses.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hack/update-godep-licenses.sh b/hack/update-godep-licenses.sh index 93f10f7df2..8d5a38c20a 100755 --- a/hack/update-godep-licenses.sh +++ b/hack/update-godep-licenses.sh @@ -75,6 +75,14 @@ process_content () { go4.org/*) package_root=$(echo ${package} |awk -F/ '{ print $1 }') ;; + gopkg.in/*) + # Root of gopkg.in package always ends with '.v(number)' and my contain + # more than two path elements. For example: + # - gopkg.in/yaml.v2 + # - gopkg.in/inf.v0 + # - gopkg.in/square/go-jose.v2 + package_root=$(echo ${package} |grep -oh '.*\.v[0-9]') + ;; *) package_root=$(echo ${package} |awk -F/ '{ print $1"/"$2 }') ;;