Skip to content

Commit 8b6fc7d

Browse files
committed
Review feedback
1 parent faaedaa commit 8b6fc7d

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

hooks/command

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,12 @@ download_binary_and_run() {
202202
}
203203

204204
run_preinstalled_binary() {
205-
local _executable="monorepo-diff-buildkite-plugin"
205+
local _executable="${executable}"
206206

207-
# Check if BINARY_FOLDER is defined and use that path
208-
if [[ -n "${BUILDKITE_PLUGIN_MONOREPO_DIFF_BINARY_FOLDER:-}" ]]; then
209-
_executable="${BUILDKITE_PLUGIN_MONOREPO_DIFF_BINARY_FOLDER%/}/${_executable}"
210-
if ! check_cmd "$_executable"; then
211-
err "Binary not found or not executable in BINARY_FOLDER: $_executable"
212-
fi
213-
else
214-
# Fall back to PATH lookup
215-
if ! check_cmd "$_executable"; then
216-
err "Binary '$_executable' not found in PATH. Please install it or set download: true"
207+
if ! check_cmd "${_executable}"; then
208+
_executable="$(basename "${executable}")"
209+
if ! check_cmd "${_executable}"; then
210+
err "Binary '$_executable' not found in PATH or binary_folder option. Please install it or set download: true"
217211
fi
218212
fi
219213

tests/command.bats

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ setup() {
99
export BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE=true
1010
# Set a minimal plugin config (only used by Go binary, not the bash hook's download logic)
1111
export BUILDKITE_PLUGINS='[{"monorepo-diff": {}}]'
12-
export BUILDKITE_PLUGINS_PATH='/etc/buildkite-agent/plugins'
1312

1413
# Create a mock binary in the current directory for download mode tests
1514
cat > "$PWD/monorepo-diff-buildkite-plugin" << 'MOCKBIN'
@@ -105,8 +104,8 @@ teardown() {
105104
export BUILDKITE_PLUGINS='[{"github.com/buildkite-plugins/monorepo-diff-buildkite-plugin#v1.0.0": {}}]'
106105

107106
# Remove mock binary so it actually needs to download
108-
rm -f "$BUILDKITE_PLUGINS_PATH/monorepo-diff-buildkite-plugin"
109-
rm -f "$BUILDKITE_PLUGINS_PATH/monorepo-diff-buildkite-plugin.version"
107+
rm -f "$PWD/monorepo-diff-buildkite-plugin"
108+
rm -f "$PWD/monorepo-diff-buildkite-plugin.version"
110109

111110
# Stub curl: fail twice on download, then succeed and create executable
112111
stub curl \
@@ -130,10 +129,9 @@ teardown() {
130129
export BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE=false
131130
# Use pinned version to skip get_latest_version API call
132131
export BUILDKITE_PLUGINS='[{"github.com/buildkite-plugins/monorepo-diff-buildkite-plugin#v1.0.0": {}}]'
133-
132+
134133
# Remove mock binary so it actually needs to download
135-
rm -f "$BUILDKITE_PLUGINS_PATH/monorepo-diff-buildkite-plugin"
136-
rm -f "$BUILDKITE_PLUGINS_PATH/monorepo-diff-buildkite-plugin.version"
134+
rm -f "$PWD/monorepo-diff-buildkite-plugin"
137135

138136
# Stub curl to always fail on download
139137
stub curl \

0 commit comments

Comments
 (0)