Skip to content

Handle UnbornBranch error for repos with no commits#148

Open
strix-tkellogg wants to merge 8 commits into
masterfrom
fix-unborn-branch
Open

Handle UnbornBranch error for repos with no commits#148
strix-tkellogg wants to merge 8 commits into
masterfrom
fix-unborn-branch

Conversation

@strix-tkellogg
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Error: UnbornBranch #128repo.head() returns ErrorCode::UnbornBranch for repos with no commits, causing error spam every poll cycle
  • capture() now handles unborn branches: uses dura/unborn branch name, diffs against empty tree, commits with no parents
  • Subsequent captures on the same unborn repo reuse the prior dura commit as parent (incremental backups work)
  • Once the user makes their first commit, dura automatically transitions to normal dura/{head_id} branch naming
  • Also removes a leftover dbg!() macro from poll_guard.rs that printed to stderr on every change detection

Test plan

  • Added unborn_branch_first_capture — verifies capture succeeds on init-only repo
  • Added unborn_branch_subsequent_capture — verifies incremental captures with no user commits
  • Added unborn_branch_transitions_to_normal — verifies switch from dura/unborn to normal naming after first commit
  • CI: existing tests should still pass (no changes to normal-case logic)
  • Manual: cargo new foo && dura serve — check that foo no longer produces error log entries

🤖 Generated with Claude Code

nextzhou and others added 2 commits March 11, 2026 13:40
Add a `dura status` subcommand that shows daemon liveness and lists
watched repositories, addressing issue #94.

Features:
- Shows whether `dura serve` is running with PID
- Lists all watched repositories from config
- Displays config file and cache directory paths
- `--json` flag for machine-readable output
- Exit code 0 when running, 1 when not running
- Cross-platform PID liveness check via sysinfo crate

Changes:
- Cargo.toml: add sysinfo dependency
- src/database.rs: add RuntimeLock::is_alive() with sysinfo-based
  process detection (replaces need for platform-specific code)
- src/main.rs: add status subcommand, --json flag, status() handler
- tests/status_test.rs: 6 integration tests covering all scenarios
- tests/util/dura.rs: add run_output() helper for capturing full output

Closes #94
When a repository has been initialized but has no commits yet,
repo.head() returns ErrorCode::UnbornBranch. Previously this
propagated as an error, causing noisy log spam every poll cycle.

Now capture() handles unborn branches by:
- Using "dura/unborn" as the branch name
- Diffing against an empty tree (all files are new)
- Creating the initial commit with no parents
- Transitioning to normal branch naming once the user commits

Also removes a leftover dbg!() macro from poll_guard.rs that
printed to stderr on every change detection.

Fixes #128

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
strix-tkellogg and others added 6 commits March 25, 2026 11:24
- actions/checkout@v3 → v4
- actions/upload-artifact@v3 → v4
- actions-rs/toolchain@v1 → dtolnay/rust-toolchain@stable (actions-rs is archived)
- actions-rs/cargo@v1 → direct cargo commands (actions-rs is archived)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Allow dead_code on Stats struct (log.rs)
- Use next_back() instead of last() on DoubleEndedIterator (metrics.rs)
- Use is_some_and() instead of map_or(false, ...) (snapshots.rs)
- Add explicit lifetime annotation on GitRepoIter return (config.rs)
- non_minimal_cfg: #[cfg(all(unix))] → #[cfg(unix)]
- needless_borrow: remove & from default_value arg
- redundant_closure: unwrap_or_else(|| fn()) → unwrap_or_else(fn)
- iter_kv_map: .iter().map(|(k,_)|...) → .keys().map(|k|...)
- for_kv_map: for (k, _) in &map → for k in map.keys()
ntapi 0.3.6 has misaligned references to packed struct fields
(E0793) which Rust 1.94 now rejects as a hard error. The 0.3.7
release fixes this. Transitive dep via tokio → mio 0.7.14.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ntapi 0.3.7 still had E0793 (misaligned packed struct references).
Updating tokio pulls mio 0.8 which drops the ntapi 0.3.x dependency
entirely, leaving only ntapi 0.4.3 which compiles clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: UnbornBranch

2 participants