-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathversion-stamp.sh
More file actions
executable file
·43 lines (38 loc) · 1.5 KB
/
version-stamp.sh
File metadata and controls
executable file
·43 lines (38 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -euo pipefail
# tested with: claude code v2.1.122
# =============================================================================
# Version Stamp: SessionEnd auto-updater
# =============================================================================
# when a session modifies files in docs/, hooks/, plugins/, or scripts/,
# auto-updates "tested with: claude code vX.Y.Z" stamps to current version.
#
# Hook type: SessionEnd
# =============================================================================
# get current claude code version
CC_VERSION=$(claude --version 2>/dev/null || echo "")
if [ -z "$CC_VERSION" ]; then
exit 0
fi
# find modified files in tracked dirs
MODIFIED=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || git diff --name-only 2>/dev/null || echo "")
if [ -z "$MODIFIED" ]; then
exit 0
fi
# filter to relevant dirs and file types
TARGETS=$(echo "$MODIFIED" | grep -E '^(docs/|hooks/|plugins/|scripts/)' | grep -E '\.(sh|md|py|json)$' || true)
if [ -z "$TARGETS" ]; then
exit 0
fi
# update stamps
while IFS= read -r file; do
if [ -f "$file" ] && grep -q 'tested with: claude code v' "$file"; then
# cross-platform sed -i: macOS needs '', GNU needs no arg
if [[ "$(uname)" == "Darwin" ]]; then
sed -i '' "s/tested with: claude code v[0-9][0-9.]*[0-9]/tested with: claude code v${CC_VERSION}/" "$file"
else
sed -i "s/tested with: claude code v[0-9][0-9.]*[0-9]/tested with: claude code v${CC_VERSION}/" "$file"
fi
fi
done <<< "$TARGETS"
exit 0