GitBaby/tests
zhenyi 61f3faed38 feat(tree): add tree_entries_with_latest + tighten RepositoryFacade sync bound
Public API additions (src/tree):
- src/tree/types.rs: new TreeEntryWithLatest { entry, latest } pair
  (entry: TreeEntry, latest: CommitInfo) with Serialize/Deserialize
  derives so it can flow through the cache payload path.
- src/tree/helper.rs: parse_ls_tree_entries — NUL/newline-delimited
  ls-tree stdout -> Vec<TreeEntry>. Mirrors the git ls-tree -r -t
  layout (mode SP type SP oid TAB name). Errors are reported with the
  1-based line index via BabyError::CommitParse for parity with
  parse_commit_output.
- src/tree/usecase.rs: GitBaby::tree_entries_with_latest(revision, path)
  -> Vec<TreeEntryWithLatest>. Implementation:
    1) spawn a single `git ls-tree -r -t <rev> -- <path>` to enumerate
       blobs/trees,
    2) parse with parse_ls_tree_entries,
    3) fan out N parallel `tree_latest_commit(rev, path)` lookups via
       tokio::task::JoinSet,
    4) reassemble preserving the ls-tree order.
  Subtree paths are normalized: tree entries get a trailing `/` for
  the lookup so callers don't have to know whether a name is a tree.
  Path safety reuses share::validate_local_no_escape, and revision
  reuses share::validate_revision_non_empty.
- src/tree/mod.rs: re-export TreeEntryWithLatest alongside the
  existing tree public surface.

Trait bound change (src/repo.rs):
- RepositoryFacade now requires Send + Sync in addition to 'static.
  This is needed so the JoinSet-driven fan-out above can share the
  Arc<dyn RepositoryFacade> across spawned tasks. Existing single-task
  implementations are unaffected; the only callers that needed to
  add Sync explicitly are those keeping non-Sync state inside their
  facade (none in-tree).

Tests (tests/tree.rs, new):
- tree_entries_with_latest_whole_tree: enumerate a flat repo and
  verify every (path, latest_commit_id) pair round-trips against the
  revwalk.
- tree_entries_with_latest_subtree: scope to a sub-path and check
  only entries under it are returned, in ls-tree order.
- tree_entries_with_latest_rejects_bad_input: empty revision and
  path-traversal attempts both surface BabyError without spawning a
  child process.
- Uses the existing TestFacade skeleton, temp_repo helper, and
  git_commit / index_commit / write_file fixtures. Counter uses
  AtomicU32 + COUNTER.fetch_add for unique temp dirs across tests,
  matching the pattern from other integration tests.

CI: cargo build + cargo test (64 passed, +3 new) green.

Notes:
- TreeEntryWithLatest has #[serde(default)] on no fields today, but
  it follows the additive-only convention documented in AGENTS.md
  (cached serde payloads only ever add new fields).
- BREAKING for RepositoryFacade implementors that are not Sync.
  None ship in-tree; downstream consumers must add Sync if they hold
  non-Sync interior state.
2026-08-14 19:23:53 +08:00
..
cmd_run.rs chore: initialize gitbaby repository 2026-08-14 18:10:04 +08:00
context.rs chore: initialize gitbaby repository 2026-08-14 18:10:04 +08:00
env.rs chore: initialize gitbaby repository 2026-08-14 18:10:04 +08:00
pipe.rs chore: initialize gitbaby repository 2026-08-14 18:10:04 +08:00
server.rs feat(server): add streaming-first server scaffolding 2026-08-14 18:13:39 +08:00
tree.rs feat(tree): add tree_entries_with_latest + tighten RepositoryFacade sync bound 2026-08-14 19:23:53 +08:00