src/holds the Rust crate: CLI entry insrc/main.rs, crate root insrc/lib.rs, subcommands undersrc/command/, shared primitives insrc/internal/, utilities insrc/utils/.- Integration tests live in
tests/command/with fixtures intests/data/;tests/command/mod.rsre-exports helpers. - Community docs in
docs/; schema bootstrapsql/sqlite_20240331_init.sql; hooks/templates intemplate/. - Buck2/Buckal metadata is in
third-party/; prefer Cargo and regenerate BUCK files when dependencies change.
cargo fmt --allthencargo clippy --all-targets --all-featureskeep formatting and linting aligned (rustfmt.tomlgroups imports by crate).cargo buildorcargo checkfor quick compile checks;cargo run -- <cmd>exercises the CLI (e.g.,cargo run -- statusin a temp repo).cargo testruns the suite; filter withcargo test command::init_testorcargo test add_test. Integration cases rely on temp dirs; run serial if flaky.- After editing
Cargo.tomldeps, runcargo buckal migrateto sync Buck2 files (seethird-party/README.md).
- Rust 2024; 4-space indent; snake_case for modules/functions, PascalCase for types, SCREAMING_SNAKE for consts.
- Imports are grouped Std/External/Crate per
rustfmt.toml; avoid wildcard imports except in tests. - Prefer
anyhow::Resultfor CLI flows andthiserrorfor library errors; keep args parsed viaclapinsrc/command/*. - Add short comments only when control flow is non-obvious (e.g., async handling, SQLite migrations).
- Favor integration coverage in
tests/command/to mirror Git workflows; usetempfile::tempdir()andutils::test::ChangeDirGuardto isolate state. - Keep fixtures small and local; re-use helpers in
tests/command/mod.rsinstead of shelling out directly. - Mark tests
#[serial]if they mutate shared state; keep async tests on Tokio (#[tokio::test]orflavor = "multi_thread"when needed). - Pair new commands/options with at least one end-to-end test plus a focused unit test where logic is easily isolated.
- History uses short, typed summaries with optional scope and PR reference, e.g.,
feat(status): support porcelain v2 (#82)orfix(push): record tracking reflog (#81). - Commits must include DCO and PGP signing:
git commit -S -s -m "feat(...): ..."; ensure theSigned-off-bytrailer is present. - PRs should state intent, linked issues, and tests run (
cargo fmt,cargo clippy,cargo test ...); include repro steps or sample CLI output when touching user-visible behavior. - Keep changes small and cohesive; update README/CLI docs when adding flags or altering compatibility tables.