fix(mkreleaselog): make robust against running in different working directories
1. Cd into the repo root before running `go list`. 2. Make sure the repo lives in the GOPATH.
Steven Allen committed
May 12, 2020 at 22:30 UTC
048c1c37b3811c1568f7a6f12ae07d2ba24935ed
1 file changed
+7
-1
bin/mkreleaselog
+7
-1
@@ -161,7 +161,13 @@ recursive_release_log() {
161
local start="${1:-$(git tag -l | sort -V | grep -v -- '-rc' | grep 'v'| tail -n1)}"
162
local end="${2:-$(git rev-parse HEAD)}"
163
local repo_root="$(git rev-parse --show-toplevel)"
164
- local package="$(go list)"
164
+ local package="$(cd "$repo_root" && go list)"
165
+
166
+ if ! [[ "${GOPATH}/${package}" != "${repo_root}" ]]; then
167
+ echo "This script requires the target package and all dependencies to live in a GOPATH."
168
+ return 1
169
+ fi
170
+
171
(
172
local result=0
173
local workspace="$(mktemp -d)"