Repository navigation
fix: handle is_bare() error in repo_path() for bare repos - #1225
worktrunk-bot wants to merge 3 commits into
Conversation
Move `--show-toplevel` check before `is_bare()` in `repo_path()` and treat `is_bare()` errors as bare. Previously `unwrap_or(false)` meant a git timeout on a bare repo would fall through to `parent()`, caching a nonsensical path. Now `Err(_)` maps to `git_common_dir`, which is correct for bare repos. For normal repos a git timeout is a bigger problem anyway, so the wrong cached path is moot. Follow-up to #1221. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
I'm slightly rethinking the original issue. I agree it was wrong to panic. But should we raise an error if we can't successfully run Are other commands likely to succeed? What are the conditions in which the fs / the repo is in a good enough state to serve us generally, while being unable to run Or is it a code simplicity thing; that it's going to cause every command to require running |
|
Good question. You're right that if The reason I went with the fallback approach rather than raising an error:
That said, if you'd prefer to raise an error eagerly, I'm happy to change |
|
In my case, this was a transient issue, and so I can't offer a clear answer to what the cause was. I'd say it's likely that any other git command run during whatever caused the timeout (presumably I/O contention from something) would have failed. Your and wt-bot's characterizations are accurate, returning a |
## Summary - Moves "Setup build tools" step **before** PR branch checkout in `claude-mention` and `claude-review` workflows - The composite action (`.github/actions/claude-setup`) only exists on `main` — checking out a PR branch created before #1273 removes it, causing the step to fail - Also adds `if: steps.verify.outcome != 'failure'` guard to the setup step in `claude-mention` (was missing) **Failed runs:** [22703855403](https://github.com/max-sixty/worktrunk/actions/runs/22703855403), [22703814015](https://github.com/max-sixty/worktrunk/actions/runs/22703814015) (both triggered on PR #1225) Fixes #1275 ## Test plan - [ ] Trigger `claude-mention` on PR #1225 (which predates #1273) and verify the setup step succeeds - [ ] Verify `claude-review` `pull_request_review` path still works 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
please could you draft this change in a PR so we can compare? |
Alternative to #1225. Changes `repo_path()` to return `anyhow::Result<&Path>` using `get_or_try_init`, propagating `is_bare()` failures to callers instead of silently caching a fallback value. This surfaces git failures (e.g., timeouts) early with clear errors rather than caching a potentially wrong path. The tradeoff is more code churn (18 files, ~20 call sites) but a cleaner failure mode. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Drafted the alternative approach in #1280. That PR changes The diff is 18 files / ~20 call sites — mostly mechanical |
|
@worktrunk-bot anything useful remaining here? |
|
This PR is superseded by #1280 (merged), which took the alternative approach of propagating |
Summary
Follow-up to #1221 (suggested by @bendrucker in #1221 (comment)).
--show-toplevelcheck beforeis_bare()inrepo_path()so submodules are handled first regardless ofis_bare()successunwrap_or(false)with amatchthat treatsErr(_)as bare — ifis_bare()fails (e.g., git timeout), we returngit_common_dirinstead ofparent(), which is the correct path for bare repos and avoids caching a nonsensical valueTest plan
cargo test --test integration bare— 21 tests)repo_pathtests pass (bare repo path, submodule path)🤖 Generated with Claude Code