fix(memory): resolve the lib dir before -C so upgrade finds the templates from a relative path
This commit is contained in:
1 parent
7052c6858e
commit
28c5a4209b
2 files changed
+10
-1
No files matched your search
+3
-1
@@ -37,6 +37,8 @@
|
||||
# of any level, fenced or not. Free text reaches awk through ENVIRON,
|
||||
# never `-v` (which expands backslash escapes).
|
||||
|
||||
# absolute before any `-C` cd: a relative $0 no longer resolves after it
|
||||
_MEM_LIB_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MEM_GREP="${MEM_GREP:-/usr/bin/grep}"
|
||||
_MEM_TABLE='decision decisions BDR
|
||||
learning learnings LRN
|
||||
@@ -677,7 +679,7 @@ _mem_upgrade_front() { # <file> → the file; one lacking a frontmatter gets
|
||||
local t first # the template's (format: 2 is added with the rest)
|
||||
IFS= read -r first < "$1"
|
||||
if [ "$first" != --- ]; then
|
||||
t="$(dirname "${BASH_SOURCE[0]}")/../templates/memory/${1##*/}"
|
||||
t="$_MEM_LIB_DIR/../templates/memory/${1##*/}"
|
||||
[ -f "$t" ] || { echo "memory: no template for $1" >&2; return 2; }
|
||||
awk 'NR > 1 && /^---$/ { print; print ""; exit }
|
||||
$0 != "format: 2"' "$t"
|
||||
|
||||
@@ -477,6 +477,13 @@ dialect nofm '^## BLK-001 — no frontmatter (2026-05-18)$'
|
||||
check T15-nofm-template "$(sed -n 1,3p d15/nofm/blockers.md | tr '\n' '#')" \
|
||||
'---#format: 2#type: blockers_registry#'
|
||||
check T15-nofm-body "$(grep -c '^# Blockers$' d15/nofm/blockers.md)" 1
|
||||
# a relative lib path plus -C from another cwd still finds the templates
|
||||
mkdir -p d15/relpath/.claude/memory
|
||||
printf '# Blockers\n\n## BLK-001 | 2026-05-18 | no frontmatter\n%s\n' \
|
||||
'- **Statut** : resolved' > d15/relpath/.claude/memory/blockers.md
|
||||
(cd "$ROOT" && bash lib/memory.sh -C "$FIX/d15/relpath" upgrade >/dev/null 2>&1)
|
||||
check T15-relpath-rc "$?" 0
|
||||
check T15-relpath-format "$(grep -c '^format: 2$' d15/relpath/.claude/memory/blockers.md)" 1
|
||||
# an em-dash heading stays byte-identical, a dated one included
|
||||
v1blk d15/keep '## BLK-001 — keep — 2026-05-18' 'Status: open'
|
||||
bash "$MEM" upgrade d15/keep >/dev/null 2>&1
|
||||
|
||||
Reference in new issue
Block a user