Skip to content

Commit 7526694

Browse files
committed
Add pre-push plugin version check; fix plugin version to 0.9.2
- Add scripts/check-plugin-version.sh: verifies plugin.json version is consistent with package.json major.minor and that no commits since the last tag changed plugin content without bumping the version - Add pre-push hook in lefthook.yml to run the check as a backstop for pre-commit bypasses (e.g. worktree agent commits) - Bump plugin version to 0.9.2 to reflect skill changes shipped in 841a27d that were missed by the pre-commit hook
1 parent 1ea8cf5 commit 7526694

3 files changed

Lines changed: 69 additions & 1 deletion

File tree

lefthook.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ pre-commit:
77
glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
88
run: bunx @biomejs/biome check --write --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {staged_files}
99
stage_fixed: true
10+
11+
pre-push:
12+
commands:
13+
check-plugin-version:
14+
run: bash scripts/check-plugin-version.sh

plugin/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "structured-context",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"description": "Structured content authoring for Obsidian — automatic validation hooks, slash commands, and agent skills to keep markdown files compliant with your schema.",
55
"homepage": "https://github.com/mindsocket/structured-context",
66
"repository": "https://github.com/mindsocket/structured-context",

scripts/check-plugin-version.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
# Verifies plugin/.claude-plugin/plugin.json version is consistent with
3+
# package.json and plugin content changes in git history.
4+
#
5+
# Checks:
6+
# - plugin major.minor must match package major.minor
7+
# - no commits since the last release tag changed plugin content without
8+
# also updating plugin.json in the same commit
9+
#
10+
# Intended for pre-push and release checks — does NOT modify any files.
11+
12+
set -euo pipefail
13+
14+
PLUGIN_JSON="plugin/.claude-plugin/plugin.json"
15+
16+
BUN=$(command -v bun 2>/dev/null || echo "$HOME/.bun/bin/bun")
17+
if ! "$BUN" --version >/dev/null 2>&1; then
18+
echo "check-plugin-version: bun not found, cannot verify" >&2
19+
exit 1
20+
fi
21+
22+
pkg_version=$("$BUN" -e "process.stdout.write(JSON.parse(require('fs').readFileSync('package.json','utf8')).version)")
23+
plugin_version=$("$BUN" -e "process.stdout.write(JSON.parse(require('fs').readFileSync('$PLUGIN_JSON','utf8')).version)")
24+
25+
IFS='.' read -r pkg_major pkg_minor _pkg_patch <<< "$pkg_version"
26+
IFS='.' read -r plugin_major plugin_minor _plugin_patch <<< "$plugin_version"
27+
28+
fail=0
29+
30+
# Check major.minor sync
31+
if [ "$pkg_major" -gt "$plugin_major" ] || { [ "$pkg_major" -eq "$plugin_major" ] && [ "$pkg_minor" -gt "$plugin_minor" ]; }; then
32+
echo "ERROR: plugin version ($plugin_version) major.minor is behind package ($pkg_version)." >&2
33+
fail=1
34+
fi
35+
36+
# Find the most recent release tag to use as the search baseline
37+
last_tag=$(git describe --tags --abbrev=0 2>/dev/null || true)
38+
range="${last_tag:+${last_tag}..}HEAD"
39+
40+
# Find commits in range where plugin content changed but plugin.json did NOT
41+
unversioned=""
42+
while IFS= read -r hash; do
43+
changed=$(git diff-tree --no-commit-id -r "$hash" --name-only)
44+
plugin_content=$(echo "$changed" | grep "^plugin/" | grep -v "^plugin/\.claude-plugin/plugin\.json$" || true)
45+
plugin_json_changed=$(echo "$changed" | grep "^plugin/\.claude-plugin/plugin\.json$" || true)
46+
if [ -n "$plugin_content" ] && [ -z "$plugin_json_changed" ]; then
47+
subject=$(git log -1 --format="%s" "$hash")
48+
unversioned="${unversioned} ${hash:0:7} ${subject}"$'\n'
49+
fi
50+
done < <(git log "$range" --format="%H")
51+
52+
if [ -n "$unversioned" ]; then
53+
echo "ERROR: plugin content changed without a version bump in:" >&2
54+
echo "$unversioned" >&2
55+
echo "Run 'bash scripts/sync-plugin-version.sh' staged with any plugin change to fix, then commit." >&2
56+
fail=1
57+
fi
58+
59+
if [ "$fail" -eq 1 ]; then
60+
exit 1
61+
fi
62+
63+
echo "Plugin version ($plugin_version) is consistent."

0 commit comments

Comments
 (0)