From 002f62edf4f04abddeb38b5c45249fbc2497e639 Mon Sep 17 00:00:00 2001 From: Jon Poole Date: Wed, 1 Nov 2023 15:43:59 +0000 Subject: [PATCH] Sort tags better --- docs/plugins/latest.go | 27 +++++++++++++++++++++++++++ docs/plugins/lint_plugin_docs.sh | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 docs/plugins/latest.go diff --git a/docs/plugins/latest.go b/docs/plugins/latest.go new file mode 100644 index 0000000000..d0f2b3650d --- /dev/null +++ b/docs/plugins/latest.go @@ -0,0 +1,27 @@ +package main + +import ( + "golang.org/x/mod/semver" + "io" + "os" + "strings" +) + +func main() { + bs, err := io.ReadAll(os.Stdin) + if err != nil { + panic(err) + } + + var latest string + for _, ver := range strings.Split(string(bs), "\n") { + if latest == "" { + latest = ver + continue + } + if semver.Compare(latest, ver) < 0 { + latest = ver + } + } + println(latest) +} diff --git a/docs/plugins/lint_plugin_docs.sh b/docs/plugins/lint_plugin_docs.sh index d04c537629..ec970fbc75 100755 --- a/docs/plugins/lint_plugin_docs.sh +++ b/docs/plugins/lint_plugin_docs.sh @@ -8,7 +8,7 @@ URL_PREFIX="https://github.com/please-build/" failed=0 for plugin in "${PLUGINS[@]}"; do - latest=$(git ls-remote --tags "${URL_PREFIX}""${plugin}"-rules.git | sed 's/.*\///' | sed '/^v[0-9]\+\.[0-9]\+\.[0-9]\+$/!d' | tail -n 1) + latest=$(git ls-remote --tags --sort=version:refname "${URL_PREFIX}""${plugin}"-rules.git | sed 's/.*\///' | sed '/^v[0-9]\+\.[0-9]\+\.[0-9]\+$/!d' | tail -n 1) if [ -z "$latest" ]; then echo "No tags found for ${plugin}" exit 1