@@ -24,7 +24,7 @@ usage() {
24
24
echo " -t <revision>: Report changes in code up to and including this revision."
25
25
echo " Default is the current working tree instead of a revision."
26
26
echo " -r <revision>: Report changes in code added since this revision."
27
- echo " Default is the common base of origin/ master and HEAD."
27
+ echo " Default is the common base of master and HEAD."
28
28
exit 1
29
29
}
30
30
@@ -53,16 +53,39 @@ if [ "$#" -ge 1 ]; then
53
53
TARGET_DIR=" $1 "
54
54
fi
55
55
56
+ # Ensure LOCAL_GOBIN is an absolute path
57
+ LOCAL_GOBIN=" $( pwd) /_output/bin"
58
+ mkdir -p " ${LOCAL_GOBIN} "
59
+
60
+ # Add cleanup trap to remove the temporary binary directory
61
+ trap ' rm -rf "${LOCAL_GOBIN}"' EXIT
62
+
56
63
# Check for apidiff tool, install it if not found
57
64
if ! command -v " ${API_DIFF_TOOL} " & > /dev/null; then
65
+ GOBIN=${LOCAL_GOBIN}
58
66
echo " Installing apidiff into ${GOBIN} ."
59
- go install golang.org/x/exp/cmd/apidiff@latest
67
+ GOBIN=${LOCAL_GOBIN} go install golang.org/x/exp/cmd/apidiff@latest
68
+ # Add GOBIN to PATH
69
+ export PATH=$PATH :${GOBIN}
60
70
fi
61
71
62
72
# Fetch common base if -r is not set
63
73
if [ -z " ${REFERENCE_REVISION} " ]; then
64
- echo " Determining common base with origin/master..."
65
- REFERENCE_REVISION=$( git merge-base origin/master HEAD)
74
+ # First try using Prow environment variables
75
+ if [ -n " ${PULL_BASE_SHA:- } " ] && [ -n " ${PULL_PULL_SHA:- } " ]; then
76
+ echo " Using Prow environment variables to determine base revision..."
77
+ if ! REFERENCE_REVISION=$( git merge-base " ${PULL_BASE_SHA} " " ${PULL_PULL_SHA} " ) ; then
78
+ echo " Error: Failed to detect base revision using Prow environment variables." >&2
79
+ exit 1
80
+ fi
81
+ else
82
+ # Fall back to upstream/master
83
+ echo " Determining common base with upstream/master..."
84
+ if ! REFERENCE_REVISION=$( git merge-base upstream/master HEAD) ; then
85
+ echo " Error: Could not determine base revision. Please set -r explicitly." >&2
86
+ exit 1
87
+ fi
88
+ fi
66
89
fi
67
90
68
91
# Step 1: Create a temporary directory for worktrees
0 commit comments