Skip to content

Commit 46011f7

Browse files
Merge pull request #126 from buildkite-plugins/revert-122-main
Revert "feat: do an update check instead of downloading binary every time"
2 parents ca07565 + e8d9fa9 commit 46011f7

2 files changed

Lines changed: 7 additions & 55 deletions

File tree

hooks/command

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,6 @@ downloader() {
6363
fi
6464
}
6565

66-
check_latest_version() {
67-
local _executable="monorepo-diff-buildkite-plugin"
68-
local _repo="https://api.github.com/repos/buildkite-plugins/monorepo-diff-buildkite-plugin"
69-
local _version=""
70-
71-
if check_cmd curl; then
72-
_version=$(curl -s "${_repo}/releases/latest" | grep -oE '"tag_name": "v[0-9]+\.[0-9]+\.[0-9]+"' | cut -d'"' -f4)
73-
elif check_cmd wget; then
74-
_version=$(wget -qO- "${_repo}/releases/latest" | grep -oE '"tag_name": "v[0-9]+\.[0-9]+\.[0-9]+"' | cut -d'"' -f4)
75-
fi
76-
77-
if [[ "$_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
78-
true
79-
else
80-
_version=""
81-
fi
82-
83-
RETVAL="$_version"
84-
}
85-
86-
check_binary_version() {
87-
local _executable="monorepo-diff-buildkite-plugin"
88-
local _version=""
89-
90-
_version=$(BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE=true ./${_executable} 2>&1 | grep -oE 'running monorepo-diff-buildkite-plugin ([0-9]+\.[0-9]+\.[0-9]+)' | cut -d' ' -f3)
91-
92-
RETVAL="v${_version}"
93-
}
94-
9566
get_version() {
9667
local _plugin=${BUILDKITE_PLUGINS:-""}
9768
local _version=""
@@ -116,35 +87,17 @@ download_binary_and_run() {
11687
local _repo="https://github.com/buildkite-plugins/monorepo-diff-buildkite-plugin"
11788

11889
get_version || return 1
119-
local _specified_version="$RETVAL"
120-
local _latest_version=""
121-
local _binary_version=""
122-
local test_mode="${BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE:-false}"
123-
local _url=""
90+
local _version="$RETVAL"
12491

125-
if check_cmd "./${_executable}"; then
126-
if check_binary_version; then
127-
_binary_version="$RETVAL"
128-
else
129-
say "Warning: Could not determine binary version, will download fresh copy"
130-
fi
131-
fi
132-
133-
if [[ "$test_mode" == "true" ]]; then
134-
true
135-
elif [ -z "${_specified_version}" ]; then
136-
check_latest_version || return 1
137-
_latest_version="$RETVAL"
138-
if [[ -z "$_binary_version" ]] || [[ "$_binary_version" != "$_latest_version" ]]; then
139-
_url=${_repo}/releases/latest/download/${_executable}_${_arch}
140-
fi
92+
if [ -z "${_version}" ]; then
93+
_url=${_repo}/releases/latest/download/${_executable}_${_arch}
14194
else
142-
if [[ -z "$_binary_version" ]] || [[ "$_binary_version" != "$_specified_version" ]]; then
143-
_url=${_repo}/releases/download/${_specified_version}/${_executable}_${_arch}
144-
fi
95+
_url=${_repo}/releases/download/${_version}/${_executable}_${_arch}
14596
fi
14697

147-
if [ -n "${_url}" ]; then
98+
local test_mode="${BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE:-false}"
99+
100+
if [[ "$test_mode" == "false" ]]; then
148101
if ! downloader "$_url" "$_executable"; then
149102
say "failed to download $_url"
150103
exit 1

main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func setupLogger(logLevel string) {
2121
var version string = "dev"
2222

2323
func main() {
24-
// This exact string is used in the command hook to grep for the version of the plugin
2524
log.Infof("--- running monorepo-diff-buildkite-plugin %s", version)
2625

2726
plugins := env("BUILDKITE_PLUGINS", "")

0 commit comments

Comments
 (0)