Skip to content

Implement pipe-delimited output and integration test suite#22

Open
rsanheim wants to merge 7 commits into
mainfrom
getting-real-with-spec
Open

Implement pipe-delimited output and integration test suite#22
rsanheim wants to merge 7 commits into
mainfrom
getting-real-with-spec

Conversation

@rsanheim

@rsanheim rsanheim commented Feb 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Update Rust implementation to conform to SPEC.md v0.2.3 three-column pipe-delimited format: repo | branch | message
  • Add Ruby/RSpec integration test suite (27 specs) covering the full Section 7.2.3 conformance table
  • Add branch resolution, ahead/behind tracking, detached HEAD handling to status command
  • Stream output progressively using head-of-line blocking (print contiguous results as they arrive)
  • Resolve git aliases (e.g. st -> status) to optimized commands

Before:

[repo-a                  ] clean
[repo-b                  ] 1 modified, 2 untracked

After:

repo-a   | main            | clean
repo-b   | feature/login   | 1 modified, 2 untracked

Rust changes

  • FormattedResult struct replaces plain String return from OutputFormatter
  • format_column() with ... truncation replaces bracket-wrapped format_repo_name()
  • Worker threads resolve branch via git rev-parse --abbrev-ref HEAD
  • Status parses git status --porcelain -b for branch, ahead/behind counts
  • --no-optional-locks added as global git option for status
  • Streaming output via head-of-line blocking with fixed branch column width (16 chars)
  • Git alias resolution: external subcommands check git config --get alias.<cmd> and route to optimized handlers when alias maps to status/pull/fetch
  • Exit code 9 when no repositories found (spec compliance)
  • GitCommand gains global_args for options that must precede -C

Integration test suite

  • spec/status_spec.rb -- 21 tests covering the full Section 7.2.3 matrix (clean, modified, added, deleted, renamed, untracked, MM, AM, detached HEAD, ahead, behind, diverged, mixed)
  • spec/output_format_spec.rb -- 5 tests for pipe format, column alignment, alphabetical ordering, truncation, exit code 9
  • spec/passthrough_spec.rb -- 1 test for passthrough output
  • spec/support/ -- git_all_runner.rb, repo_builder.rb, output_parser.rb
  • script/test -t spec runs the integration suite

Test plan

  • All 39 Rust unit tests pass (cargo test)
  • All 27 integration specs pass (script/test -t spec)
  • All 3 implementations pass (script/test)
  • Manual verification of output format with real repos

Update Rust implementation to conform to SPEC.md v0.2.2 three-column
pipe-delimited output format: `repo | branch | message`.

Rust changes:
- Add FormattedResult struct and update OutputFormatter trait
- Replace bracket-wrapped format_repo_name with format_column using `...` truncation
- Add branch resolution via rev-parse in worker threads
- Parse branch line from `git status --porcelain -b` with ahead/behind support
- Handle detached HEAD as `HEAD (detached)`
- Add --no-optional-locks as global git option for status
- Collect-then-print in run_parallel for aligned column widths
- Exit code 9 when no repositories found

Integration test suite (Ruby/RSpec):
- 26 specs covering full Section 7.2.3 test matrix
- Real git repos in tmpdirs for each test
- Tests for pipe-delimited format, column alignment, ordering, truncation
* Make RepoBuilder#git public, remove duplicated git_in from specs
* Extract with_tracking_repo helper for upstream/clone boilerplate
* Add FormattedResult::message_only constructor for fetch/pull/status
When an external subcommand matches a git alias (e.g. `st` -> `status`),
route it to the optimized handler instead of falling through to passthrough.
Replace collect-then-print with streaming: as each result arrives,
print all contiguous results from the front of the queue immediately.
Use a fixed branch column width (14 chars) so output can stream
without waiting for all results to compute column widths.
Fixed branch column at 14 chars and added streaming output via
head-of-line blocking as RECOMMENDED behavior.
14 chars truncated "HEAD (detached)" (15 chars). Bump to 16 so
detached HEAD displays without truncation.
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.

1 participant