Fix gateway advertising 'unknown' version in production installs
hermes plugins install <repo>#gateway-plugin ships ONLY the gateway-plugin/ subdirectory into ~/.hermes/plugins/iris, so the repo-root VERSION file is not present there and plugin_version() fell back to 'unknown' — the app then showed a false 'App and gateway versions differ' warning. - version.py: resolution chain repo-root VERSION (dev/symlink install) -> plugin.yaml version field (production install) -> 'unknown'; stdlib-only parse, base= param for tests - plugin.yaml: bump stale version 0.1.0 -> 0.1.2 (matches VERSION) - scripts/check_version_sync.sh + pre-commit hook: fail commits where plugin.yaml drifts from the repo-root VERSION - tests: regression test simulating the production layout
This commit is contained in:
1 parent
ea375fd88c
commit
0f5b5a16ab
5 files changed
+148
-16
No files matched your search
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
# Fail the commit if gateway-plugin/plugin.yaml's `version:` field drifts
|
||||
# from the repo-root VERSION file (the single source of truth).
|
||||
#
|
||||
# Why: `hermes plugins install <repo>#gateway-plugin` ships ONLY the
|
||||
# gateway-plugin/ subdirectory into ~/.hermes/plugins/iris, so in production
|
||||
# the gateway advertises the version from plugin.yaml (see
|
||||
# gateway-plugin/version.py). If the two drift, the app shows a false
|
||||
# "versions differ" warning.
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(git rev-parse --show-toplevel)"
|
||||
version_file="$repo_root/VERSION"
|
||||
plugin_yaml="$repo_root/gateway-plugin/plugin.yaml"
|
||||
|
||||
[ -f "$version_file" ] || {
|
||||
echo "check_version_sync: missing $version_file" >&2
|
||||
exit 1
|
||||
}
|
||||
[ -f "$plugin_yaml" ] || {
|
||||
echo "check_version_sync: missing $plugin_yaml" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
root_version="$(tr -d '[:space:]' <"$version_file")"
|
||||
# Mirrors gateway-plugin/version.py's _VERSION_RE: optional single OR double
|
||||
# quote, at least one captured character.
|
||||
yaml_version="$(sed -n "s/^version:[[:space:]]*[\"']\{0,1\}\([^\"'[:space:]]\{1,\}\).*/\1/p" "$plugin_yaml" | head -n1)"
|
||||
|
||||
if [ -z "$yaml_version" ]; then
|
||||
echo "check_version_sync: no top-level 'version:' field in gateway-plugin/plugin.yaml" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$root_version" != "$yaml_version" ]; then
|
||||
echo "check_version_sync: version drift" >&2
|
||||
echo " VERSION (repo root) = $root_version" >&2
|
||||
echo " gateway-plugin/plugin.yaml = $yaml_version" >&2
|
||||
echo "Bump both to the same value (VERSION is the source of truth)." >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user