fix: account for CWD when building git ls-tree pathspecs - #75
Conversation
git ls-tree pathspecs are CWD-relative. When the tool runs in same-repo mode, setup_docs_environment() does os.chdir(DOCS_SUBFOLDER), so CWD is inside the docs folder. The ref-based functions then built pathspecs like "docs/commands" — but from inside docs/, git interpreted this as "docs/docs/commands" which doesn't exist, returning empty results. Added _get_effective_subfolder() that checks whether CWD is already inside the docs subfolder (same logic as get_docs_root()) and omits the prefix when it is. This caused [review-docs] on merged PRs to skip all index operations and return "No documentation updates needed" (seen on crane PR #790). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 8:21 AM UTC · Completed 8:37 AM UTC Commit: |
ReviewFindingsLow
Previous runReviewFindingsLow
Previous run (2)ReviewFindingsMedium
Low
Labels: PR fixes a bug in Python source code (CWD-relative pathspec handling in doc_index.py) Next steps:
|
git cat-file and git show require tree-root-relative paths, but after the ls-tree pathspec fix, file paths are CWD-relative. Using the ./ prefix (e.g., origin/main:./commands/export.md) tells git to resolve relative to CWD, matching the ls-tree output. Without this, content retrieval silently failed (returncode != 0), producing empty hash dicts and content lists — same broken behavior as before the pathspec fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 8:42 AM UTC · Completed 8:55 AM UTC Commit: |
Superseded by updated review
Replace the Path.exists() check in _get_effective_subfolder() with git rev-parse --show-prefix, which reliably reports CWD's position within the repo. Avoids false results if the subfolder contains a same-named sub-directory (e.g., docs/docs/). Update tests to mock _get_effective_subfolder directly instead of relying on filesystem state. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 9:06 AM UTC · Completed 9:19 AM UTC Commit: |
| result = run_command_safe(["git", "rev-parse", "--show-prefix"], check=False) | ||
| if result.returncode == 0: | ||
| prefix = result.stdout.strip().rstrip("/") | ||
| if prefix == docs_subfolder: |
There was a problem hiding this comment.
[low] edge-case
_get_effective_subfolder() uses exact equality (prefix == docs_subfolder) to detect when CWD is inside the docs subfolder. If CWD were deeper than the subfolder root (e.g., docs/commands/ while DOCS_SUBFOLDER is docs), the prefix would not match and the function would return the full subfolder, producing a double-prefixed pathspec. In current code, setup_docs_environment() only does os.chdir(docs_subfolder) (never deeper), so this edge case is not triggered today.
Suggested fix: Consider adding a comment documenting the assumption that CWD is exactly the subfolder root, never deeper.
|
🤖 Finished Retro · ✅ Success · Started 9:36 AM UTC · Completed 9:56 AM UTC Commit: |
Retro: PR #75 — fix: account for CWD when building git ls-tree pathspecsWhat happenedPR #75 was a human-authored bugfix (co-authored with Claude Opus 4.6) that fixed CWD-relative pathspec construction in
The PR was merged by the author after agent-only review (no human reviewers participated). What went well
Known inefficiencies (all tracked by existing issues)
No new proposalsThis workflow executed well. The review agent provided genuine value by catching an incomplete fix before merge. All identified inefficiencies are tracked by existing open issues in the agents repo. No novel proposals are warranted. |
Summary
git ls-treepathspecs are CWD-relative. In same-repo mode,setup_docs_environment()doesos.chdir(DOCS_SUBFOLDER), so CWD is inside the docs folder. The ref-based functions (get_folder_doc_hashes_from_ref,_get_docs_content_from_ref) built pathspecs likedocs/commands— but from insidedocs/, git interpreted this asdocs/docs/commandswhich doesn't exist, returning empty results.This caused
[review-docs]on merged PRs to skip all index operations and return "No documentation updates needed" even when docs needed updating (seen on migtools/crane PR #790).Fix
Added
_get_effective_subfolder()that checks whether CWD is already inside the docs subfolder (same logic asget_docs_root()) and omits the prefix when it is.Test plan
git ls-tree origin/main -- docsreturns 0 results from insidedocs/git ls-tree origin/main -- .returns correct results from insidedocs/🤖 Generated with Claude Code