Skip to content

Commit 03d9441

Browse files
committed
fix: update apidiff script to install tool and set up remote repository
1 parent 23d89dc commit 03d9441

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea
2+
_output/

Diff for: hack/apidiff.sh

+20-3
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,33 @@ if [ "$#" -ge 1 ]; then
5353
TARGET_DIR="$1"
5454
fi
5555

56+
# Create a temporary local GOBIN under _output/
57+
LOCAL_GOBIN="$(pwd)/_output/bin"
58+
mkdir -p "${LOCAL_GOBIN}"
59+
5660
# Check for apidiff tool, install it if not found
5761
if ! command -v "${API_DIFF_TOOL}" &> /dev/null; then
62+
GOBIN=${LOCAL_GOBIN}
5863
echo "Installing apidiff into ${GOBIN}."
59-
go install golang.org/x/exp/cmd/apidiff@latest
64+
GOBIN=${LOCAL_GOBIN} go install golang.org/x/exp/cmd/apidiff@latest
65+
# Add GOBIN to PATH
66+
export PATH=$PATH:${GOBIN}
6067
fi
6168

69+
# Ensure the remote is set
70+
if ! git remote get-url origin &> /dev/null; then
71+
echo "Error: 'origin' remote is not set. Please add the remote using:"
72+
echo "git remote add origin https://github.com/kubernetes-sigs/structured-merge-diff.git"
73+
exit 1
74+
fi
75+
76+
# Fetch the latest changes from the remote
77+
git fetch origin
78+
6279
# Fetch common base if -r is not set
6380
if [ -z "${REFERENCE_REVISION}" ]; then
64-
echo "Determining common base with origin/master..."
65-
REFERENCE_REVISION=$(git merge-base origin/master HEAD)
81+
echo "Determining common base with upstream/master..."
82+
REFERENCE_REVISION=$(git merge-base upstream/master HEAD)
6683
fi
6784

6885
# Step 1: Create a temporary directory for worktrees

0 commit comments

Comments
 (0)