-
Notifications
You must be signed in to change notification settings - Fork 27
fix(recovery): probe for a free attempt-preserve-dirty ref name #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -524,6 +524,21 @@ def snapshot_worktree( | |||||||||||||||||||||||||||||||||||||||
| return ref_name | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| def ref_exists(repo: Path, refname: str) -> bool: | ||||||||||||||||||||||||||||||||||||||||
| """Whether ``refname`` — a FULL refname, e.g. ``refs/attempt-preserve-dirty/…`` | ||||||||||||||||||||||||||||||||||||||||
| — currently exists. Sibling of :func:`branch_exists`, which prepends | ||||||||||||||||||||||||||||||||||||||||
| ``refs/heads/`` and so cannot see the snapshot refs that live outside it. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| A non-zero exit reads as "absent" — `show-ref --verify` returns 1 for both a | ||||||||||||||||||||||||||||||||||||||||
| missing ref and a malformed name, and the caller's subsequent ref write | ||||||||||||||||||||||||||||||||||||||||
| surfaces any real error. Spawn and timeout faults are NOT swallowed: they | ||||||||||||||||||||||||||||||||||||||||
| arrive typed from `_run_git` as GitError/GitSpawnError and propagate, so a | ||||||||||||||||||||||||||||||||||||||||
| caller that must not overwrite an existing ref cannot mistake "git could not | ||||||||||||||||||||||||||||||||||||||||
| run" for "the name is free".""" | ||||||||||||||||||||||||||||||||||||||||
| rc, _ = _git(repo, "show-ref", "--verify", "--quiet", refname) | ||||||||||||||||||||||||||||||||||||||||
| return rc == 0 | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+527
to
+539
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Make
Proposed fix- rc, _ = _git(repo, "show-ref", "--verify", "--quiet", refname)
+ try:
+ rc, _ = _git(repo, "show-ref", "--verify", "--quiet", refname)
+ except GitError:
+ return False
return rc == 0Based on coding guidelines, observation may degrade, but repair writes must raise. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| def safe_rollback( | ||||||||||||||||||||||||||||||||||||||||
| repo: Path, | ||||||||||||||||||||||||||||||||||||||||
| baseline: str, | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.