fix(code-limits): resolve physical path so symlinked dirs see tracked files
This commit is contained in:
1 parent
9d928a266a
commit
db2937d8b7
2 files changed
+14
No files matched your search
@@ -68,6 +68,11 @@ columns: $list; our code keeps $LIMIT (CLAUDE.md Limits)." \
|
||||
'{hookSpecificOutput:{hookEventName:"PostToolUse",additionalContext:$c}}'
|
||||
}
|
||||
|
||||
physical_path() { # physical_path <file>: dir symlinks resolved (BSD-safe)
|
||||
local dir; dir="$(cd "$(dirname "$1")" 2>/dev/null && pwd -P)" || return 1
|
||||
printf '%s/%s' "$dir" "$(basename "$1")"
|
||||
}
|
||||
|
||||
checkable() { # checkable <file> <session>: worth reading at all
|
||||
[[ "$1" =~ $EXT_RE ]] && [[ "$2" =~ $SID_RE ]] && [ -f "$1" ] \
|
||||
&& [ "$(wc -c < "$1")" -le "$MAX_BYTES" ]
|
||||
@@ -79,6 +84,7 @@ main() {
|
||||
local file sid dir mark hits
|
||||
file="$(field .tool_input.file_path)"; sid="$(field .session_id)"
|
||||
checkable "$file" "$sid" || return 0
|
||||
file="$(physical_path "$file")" || return 0
|
||||
[ -n "$(field .tool_input.new_string)" ] && export CL_EDIT=1
|
||||
dir="${TMPDIR:-/tmp}/claude-code-limits-$sid"
|
||||
mark="$dir/$(hash16 "$file")"
|
||||
|
||||
@@ -73,5 +73,13 @@ check T14-no-commit-not-cached \
|
||||
"$(find "$TMPDIR/claude-code-limits-s9" -name 'origin-*' | wc -l \
|
||||
| tr -d ' ')" 0
|
||||
|
||||
# a tracked file reached through a symlinked dir: only the new line counts
|
||||
mkdir -p "$WORK/ours/sub" && ln -s "$WORK/ours/sub" "$WORK/link"
|
||||
printf '%s\n' "$big" > "$WORK/ours/sub/t.sh"
|
||||
git -C "$WORK/ours" add sub/t.sh && git -C "$WORK/ours" commit -q -m t
|
||||
echo short >> "$WORK/ours/sub/t.sh"
|
||||
x="$(jq -n --arg c "$(cat "$WORK/ours/sub/t.sh")" '{content:$c}')"
|
||||
check T15-symlinked-dir-tracked "$(fire "$WORK/link/t.sh" s10 "$x")" ""
|
||||
|
||||
printf 'PASS=%d FAIL=%d\n' "$pass" "$fail"
|
||||
[ "$fail" -eq 0 ]
|
||||
Reference in new issue
Block a user