fix: preserve offline repo fallbacks - #825
Conversation
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f42929c061
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| match git::fetch_for_worktree(repo_path, repo_slug, branch_name, base_branch) { | ||
| Ok(()) => Ok(()), | ||
| Err(fetch_err) => { | ||
| if let Some(base_ref) = local_base_ref_for_worktree(repo_path, base_branch) { |
There was a problem hiding this comment.
Avoid reusing stale bases when the remote rejects them
When the remote is reachable but the configured base branch was deleted or renamed, git fetch origin <base> fails with couldn't find remote ref <base>. This branch treats every fetch failure as an offline case whenever a stale origin/<base> exists locally, so setup can create a new worktree from a base that the remote has already rejected instead of surfacing the bad base branch. Please gate this fallback to connectivity/auth failures, or at least exclude missing-remote-ref errors before returning Ok(()).
Useful? React with 👍 / 👎.
| let Some(relative_path) = normalize_repo_subpath(subpath)? else { | ||
| return Ok(true); | ||
| }; | ||
| Ok(clone_path.join(relative_path).is_dir()) |
There was a problem hiding this comment.
Validate fallback subpaths against the Git tree
When GitHub validation fails, this checks the clone's live filesystem rather than repository contents, so offline validation accepts directories that are not valid repo subpaths, such as .git, generated/untracked folders like node_modules, or symlinks that point to directories outside the checkout. Those accepted subpaths are later stored and joined into worktree paths (for example in prs.rs), which can make sessions/PR operations fail or operate outside the intended repo. Please validate against a Git tree/ref or explicitly reject untracked, .git, and symlinked paths in the local fallback.
Useful? React with 👍 / 👎.
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Summary
Tests