Repository navigation
Practices Studies Gitui
gitui is a keyboard-driven terminal user interface for Git, self-described in extras/gitui/Cargo.toml as a "blazing fast terminal-ui for git". It is one of the most widely installed Rust TUIs in industry: the README installation section at extras/gitui/README.md lists packaged builds for Fedora (dnf), openSUSE (zypper), Homebrew, MacPorts, winget, scoop, chocolatey, FreeBSD pkg, and conda-forge, which is a good proxy for real-world adoption. Engineers reach for it because it wraps libgit2 and gitoxide behind an async job system so that even huge repositories (the Makefile keeps commented run targets against the Linux and Kubernetes trees in extras/gitui/Makefile) stay responsive.
Measured from the clone at commit 2fa693c:
- 162 Rust source files, 50,372 lines of Rust across the repository.
- 7 crates: the root binary plus 6 library crates. extras/gitui/Cargo.toml declares five workspace members explicitly, and
invalidstringjoins the workspace as a path dependency of asyncgit:
[workspace]
members = [
"asyncgit",
"filetreelist",
"git2-hooks",
"git2-testing",
"scopetime",
]- Line counts per crate:
src(the binary) 29,418;asyncgit17,145;filetreelist1,953;git2-hooks1,631;git2-testing97;scopetime68;invalidstring11. - 318
#[test]functions across the workspace (177 in asyncgit, 79 in the binary crate, 62 in filetreelist and git2-hooks combined).
extras/gitui/
|-- Cargo.toml root package + workspace definition
|-- build.rs embeds git hash and build date into the version string
|-- src/ the gitui binary: app loop, UI, input
| |-- components/ reusable widgets (diff, commitlist, textinput, ...)
| |-- popups/ 31 modal dialogs (commit, push, fetch, blame, ...)
| |-- tabs/ the five main screens (status, revlog, files, ...)
| |-- ui/ low-level drawing helpers (scrollbar, reflow, style)
| |-- keys/ keybinding model, RON override loading
| `-- snapshots/ insta .snap files for full-terminal snapshots
|-- asyncgit/ all Git logic; sync/ has blocking ops, the rest wraps
| | them in background jobs over crossbeam channels
|-- filetreelist/ pure data structure crate: foldable sorted path tree
|-- git2-hooks/ git hook discovery/execution on top of git2-rs
|-- git2-testing/ test helper crate: temp-repo constructors
|-- invalidstring/ one function producing invalid UTF-8 test data
|-- scopetime/ feature-gated scope timing macro
|-- .github/workflows/ ci.yml, cd.yml, nightly.yml, brew.yml
|-- wix/ Windows MSI packaging sources
|-- deny.toml, typos.toml, tombi.toml, rustfmt.toml, .clippy.toml
`-- CHANGELOG.md, KEY_CONFIG.md, THEMES.md, FAQ.md, NIGHTLIES.md
The split works because each extracted crate has a single reason to exist and a strictly smaller dependency set than the binary. asyncgit is the whole Git domain layer and never touches ratatui; the UI crate never links git2 directly. filetreelist is pure logic with only thiserror as a dependency (extras/gitui/filetreelist/Cargo.toml), so its folding and navigation algorithms are testable without a repository. Test-only concerns get their own crates (git2-testing, invalidstring) so production crates never carry test scaffolding, and dev-only helpers are wired in via [dev-dependencies] (extras/gitui/asyncgit/Cargo.toml). The crate boundary is also the documentation boundary: extras/gitui/src/main.rs opens with a module map explaining exactly this layering.
The root manifest at extras/gitui/Cargo.toml is both the binary package and the workspace root. Notable practices:
- MSRV and edition are pinned in the package table:
edition = "2021"andrust-version = "1.88". The same MSRV appears in.clippy.tomland as an explicit row in the CI matrix, so the claim is enforced three ways. - There is no
[workspace.package]inheritance and no[workspace.dependencies]: every member repeatsauthors,edition,license,homepage,repository(see extras/gitui/asyncgit/Cargo.toml and extras/gitui/filetreelist/Cargo.toml). Each member is independently published to crates.io, which is why each carries full metadata,categories, andkeywords. Path dependencies always pair apathwith aversionso publishing works:asyncgit = { path = "./asyncgit", version = "0.28.1", default-features = false }. One unusual bound:filetreelist = { path = "./filetreelist", version = ">=0.6" }. - Crates-io hygiene:
exclude = [".github/*", ".vscode/*", "assets/*"]keeps the published tarball small, and filetreelist excludes its demo gif (exclude = ["/demo.gif"]). - Feature flags document their constraints inline:
[features]
default = ["ghemoji", "regex-fancy", "trace-libgit", "vendor-openssl"]
ghemoji = ["gh-emoji"]
# regex-* features are mutually exclusive.
regex-fancy = ["syntect/regex-fancy", "two-face/syntect-fancy"]
regex-onig = ["syntect/regex-onig", "two-face/syntect-onig"]
timing = ["scopetime/enabled"]Features are thin: each one either renames an optional dependency (ghemoji = ["gh-emoji"]) or forwards to a member crate (vendor-openssl = ["asyncgit/vendor-openssl"], which in extras/gitui/asyncgit/Cargo.toml enables an optional openssl-sys with features = ["vendored"]).
- Profiles are tuned for the product. Debug builds keep the UI fast by optimizing only the hot dependency, and release optimizes for binary size:
[profile.dev.package."ratatui"]
opt-level = 3
[profile.release]
opt-level = "z" # Optimize for size.
strip = "debuginfo"
lto = true
codegen-units = 1- Dependencies are alphabetized, and
default-features = falseis applied aggressively (chrono,ratatui,syntect,simplelog,bytesize,two-face) to keep the dependency tree and binary small. - There is no
[lints]table anywhere; lint policy lives in crate-level attributes (section 5). - extras/gitui/rust-toolchain.toml pins only
channel = "stable"withprofile = "default", so contributors build on current stable while CI separately guards the MSRV. - extras/gitui/.cargo/config.toml maps cross linkers per target, e.g.
[target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc".
extras/gitui/rustfmt.toml is three lines, all stable options:
max_width = 70
hard_tabs = true
newline_style = "Unix"-
max_width = 70: far below the default 100. The codebase is designed to be read in narrow terminal splits next to the running TUI; it also forces short expressions and early extraction of locals. -
hard_tabs = true: indentation is tab characters, so each reader chooses their own indent width. This is paired with the editor layer: extras/gitui/.editorconfig declaresroot = trueand, for[*.rs],indent_style = tab, so non-rustfmt editors agree with rustfmt. -
newline_style = "Unix": normalizes line endings across the Windows contributors the project demonstrably has (there is a full Windows CI leg and MSI packaging).
Non-Rust formatting is also enforced. TOML files are formatted with tombi, configured at extras/gitui/tombi.toml with an MSRV-driven constraint, explained in place:
# Keep dependency inline tables on a single line. Multi-line inline tables are
# TOML 1.1 syntax that Cargo on our MSRV (rust 1.88) rejects with
# "invalid inline table", so tombi must not expand them.
[format.rules]
line-width = 220CI runs tombi format --check in the linting job (extras/gitui/.github/workflows/ci.yml) and the Makefile aliases it as make sort. Spelling is checked by typos with extras/gitui/typos.toml, which whitelists project words (ratatui = "ratatui") and excludes the changelog via extend-exclude = ["CHANGELOG.md"]. Editor auto-format is switched on for contributors in extras/gitui/.vscode/settings.json ("editor.formatOnSave": true).
Clippy configuration lives in two places: a tiny .clippy.toml and per-crate attribute walls.
extras/gitui/.clippy.toml:
msrv = "1.88.0"
cognitive-complexity-threshold = 18Setting msrv stops clippy from suggesting APIs newer than the supported compiler; lowering cognitive-complexity-threshold below the default 25 makes the nursery complexity lint bite earlier.
The binary crate wall at extras/gitui/src/main.rs:
#![forbid(unsafe_code)]
#![deny(
mismatched_lifetime_syntaxes,
unused_imports,
unused_must_use,
dead_code,
unstable_name_collisions,
unused_assignments
)]
#![deny(clippy::all, clippy::perf, clippy::nursery, clippy::pedantic)]
#![deny(
clippy::unwrap_used,
clippy::filetype_is_file,
clippy::cargo,
clippy::panic,
clippy::match_like_matches_macro
)]The philosophy is visible in what is denied versus allowed. Denied: whole groups (all, perf, nursery, pedantic, cargo) plus the crash-preventing restriction lints unwrap_used and panic. Allowed: a short, justified list (module_name_repetitions, multiple_crate_versions, bool_to_int_with_if, and two false-positive-prone lints). Aspirations are recorded as commented deny lines, e.g. in extras/gitui/asyncgit/src/lib.rs:
//TODO: get this in someday since expect still leads us to crashes sometimes
// clippy::expect_usedEach crate tunes its own wall: asyncgit adds #![forbid(missing_docs)] and deprecated, and allows missing_errors_doc and must_use_candidate (a library-appropriate relaxation), while stricter sub-modules escalate locally: extras/gitui/asyncgit/src/asyncjob/mod.rs opens with #![deny(clippy::expect_used)], proving the aspirational lint one module at a time. git2-testing allows unsafe_code only via a function-scoped #[allow(unsafe_code)] instead of dropping the crate-wide guarantee.
Beyond clippy, the check infrastructure is aggregated in extras/gitui/Makefile:
check: fmt clippy test sort denywith deny running cargo deny check against extras/gitui/deny.toml. That file is a model of documented exceptions: a license allowlist of ten SPDX ids, one advisory ignore with a linked reason ({ id = "RUSTSEC-2025-0141", reason = "Only brought in via syntect" }), and multiple-versions = "deny" under [bans] where every skip-tree entry carries a comment naming the offending dependency and, where available, the upstream issue link. CI adds cargo udeps (unused dependency detection) as a separate nightly-toolchain job.
Four workflows live in extras/gitui/.github/workflows.
ci.yml triggers on a nightly cron ("0 2 * * *"), on push to every branch (branches: ["*"]), and on pull requests to master. Its jobs:
-
build: a 3x3 matrix,os: [ubuntu-latest, macos-latest, windows-latest]byrust: [nightly, stable, "1.88"], withfail-fast: falseandcontinue-on-error: ${{ matrix.rust == 'nightly' }}. Pinning the literal MSRV as a matrix row means an accidental use of a newer API fails CI, while the nightly row is an early-warning canary that cannot block merges. Steps:Swatinem/rust-cache@v2with ashared-keycomposed of os, cache name, and toolchain;dtolnay/rust-toolchain@masterwith the matrix toolchain; nextest installed viataiki-e/install-action@nextest; debug build,make test,make clippy,make build-release; thencargo install --path "." --force --lockedas a packaging smoke test; binary size listing per OS;otool -Lon macOS to audit dynamic library linkage; andcargo wixon Windows to prove the MSI still builds. It even installs signing tools (gpgsm, gnupg) because the test suite includes real end-to-end commit-signing tests. -
build-linux-musl: same three toolchains againstx86_64-unknown-linux-musl, running the full suite withmake test-linux-musland checking--versionoutput of both debug and release binaries. -
build-linux-arm: cross-compiles aarch64, armv7, and arm targets with vendor GCC toolchains, then actually executes the aarch64 test binaries under emulation by exportingCARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER: qemu-aarch64-static -L /usr/aarch64-linux-gnu. Very few projects run their tests on a foreign architecture in CI. -
build-apple-x86: cross-builds the Intel macOS binary from Apple Silicon runners. -
linting:cargo fmt -- --check,tombi format --check, andcargo deny check. -
udeps: nightly toolchain pluscargo +nightly udeps --all-targets. -
log-test("Changelog Test"): runsffurrer2/extract-release-notes@v2on every PR and uploads the result, guaranteeing the changelog stays machine-extractable before release day. -
test-homebrew:brew install --build-from-source gituion macOS, verifying the downstream formula still builds from source.
Actions are pinned by major tag (actions/checkout@v4, Swatinem/rust-cache@v2, softprops/action-gh-release@v2), not by SHA. cd.yml triggers on tag push and workflow_dispatch, and is the only workflow that requests write permission, minimally scoped:
permissions:
contents: writeThe release job re-runs tests and clippy per OS, builds all release artifacts via Makefile targets (release-mac, release-mac-x86, release-linux-musl, release-win, release-linux-arm), computes a SHA256 for the mac tarball, extracts the release body from CHANGELOG.md with the same extract-release-notes action CI validated, publishes with softprops/action-gh-release@v2 using prerelease: ${{ contains(github.ref, '-') }}, and finally bumps the homebrew-core formula through mislav/bump-homebrew-formula-action@v3, skipping prereleases. nightly.yml rebuilds all artifacts on a 3 a.m. cron and uploads them to an S3 bucket (AWS_BUCKET_NAME: s3://gitui/nightly/), documented for users in extras/gitui/NIGHTLIES.md. brew.yml is a manual re-run of the formula bump with a tag-name input for when the automatic bump fails.
Repo automation beyond workflows: extras/gitui/.github/dependabot.yml runs cargo updates daily and groups them (cargo-minor and cargo-patch groups with patterns: ["*"]), collapsing dependency noise into two rolling PRs; extras/gitui/.github/stale.yml marks issues dormant after 180 days with pinned, security, and nostale exemptions. No merge-queue configuration is present in the repository; branch protection is configured server-side and not visible from the clone.
There are no tests/ directories anywhere in the workspace; all 318 tests are colocated #[cfg(test)] mod tests blocks inside the modules they cover (49 files contain a mod tests). The split by crate mirrors the architecture: the Git domain logic in asyncgit carries the bulk (177 tests, e.g. staging, rebase, hooks, signing under extras/gitui/asyncgit/src/sync/), pure data structures in filetreelist and hook logic in git2-hooks carry 62, and the binary crate has 79 including full-application tests.
The harness infrastructure is layered:
-
git2-testing(extras/gitui/git2-testing/src/lib.rs) providesrepo_init_empty,repo_init,repo_init_bare, andrepo_init_suffix, each returning(TempDir, Repository)with committer identity preconfigured. Crucially it also sandboxes global Git state so developer machines cannot influence tests:
// Adapted from https://github.com/rust-lang/cargo/pull/9035
INIT.call_once(|| unsafe {
let temp_dir = TempDir::new().unwrap();
let path = temp_dir.path();
set_search_path(ConfigLevel::System, path).unwrap();
set_search_path(ConfigLevel::Global, path).unwrap();-
invalidstring(extras/gitui/invalidstring/src/lib.rs) manufactures invalid UTF-8 strings so path and message handling is tested against hostile data. - Snapshot testing: the whole application is driven headlessly in extras/gitui/src/gitui.rs using ratatui's
TestBackend, and terminal frames are asserted with insta. A local macro normalizes nondeterminism before comparison:
macro_rules! apply_common_filters {
{} => {
let mut settings = insta::Settings::clone_current();with filters that rewrite temp directories to [TEMP_FILE] and 7-char commit ids after a box-drawing bar to [AAAAA]. The gitui_starts test boots the app on a fresh repo, snapshots the loading frame, injects an AsyncGitNotification::Status, snapshots again, then synthesizes key events to switch tabs and snapshots the log view. Snapshots live at extras/gitui/src/snapshots/*.snap. The dev-dependency enables filters explicitly: insta = { version = "1.41.0", features = ["filters"] }.
- End-to-end external-tool tests: extras/gitui/asyncgit/src/sync/sign.rs contains
test_x509_sign_and_verify_e2e, which shells out to realopensslandgpgsmto build a throwaway X.509 identity, signs an actual commit, and verifies it. It is#[cfg(unix)]and#[serial](viaserial_test) because it mutates the process-wideGNUPGHOME. CI installsgpgsmon Linux and gnupg on macOS specifically for these tests. - Runner:
cargo nextest run --workspaceis the canonical test command (extras/gitui/Makefiletest:target), with per-target variantstest-linux-muslandtest-linux-arm; the ARM variant demonstrates nextest's filter expressions by excluding one kernel-behavior-dependent test:-E 'not test(test_hook_with_missing_shebang)'. -
pretty_assertionsis a dev-dependency of every crate with tests, andenv_loggeris initialized per test viagit2-testing::init_logwithis_test(true).
There is no fuzzing, property testing, or benches/ directory in the repository; performance work is done ad hoc through make profile (cargo flamegraph --features timing) and the scopetime instrumentation instead. The public surface (a flag-only CLI) is covered indirectly: CI executes the built binary (./target/.../gitui --version) on musl and validates cargo install on every OS.
Two smaller habits round out the harness. First, the application object is factored so tests can drive it: Gitui in extras/gitui/src/gitui.rs exposes input_event, update_async, and wait_for_async_git_notification methods that the snapshot test calls directly, meaning the production event loop and the test share the same code path rather than a parallel test-only harness. Second, snapshot temp directories are made recognizable on purpose: repo_init_suffix(Some("-insta")) (extras/gitui/git2-testing/src/lib.rs) creates temp dirs ending in -insta precisely so the insta filter regexes can find and redact them on all three operating systems.
The repository uses the classic two-tier scheme: thiserror in libraries, anyhow in the binary.
- extras/gitui/asyncgit/src/error.rs defines a single crate-wide
Errorenum with#[from]conversions for io, git2, UTF-8, integer conversion, threadpool, hooks, and signing errors, plus domain variants with user-readable messages such as#[error("git: no head found")] NoHeadand#[error("git: uncommitted changes")] UncommittedChanges. A nestedGixErrorenum isolates the highly granular gitoxide error types, and large variants are boxed to keep the enum small:Discover(#[from] Box<gix::discover::Error>). - The signing module keeps two purpose-specific error enums (
SignBuilderError,SignError) next to theSigntrait in extras/gitui/asyncgit/src/sync/sign.rs, so construction failures and runtime failures are distinct types. - The binary crate uses
anyhow::Resultend to end;mainitself returnsResult<()>(extras/gitui/src/main.rs) and context is attached at the boundary, e.g. in extras/gitui/src/args.rs:fs::create_dir_all(&confpath).with_context(|| format!("failed to create config directory: {}", confpath.display()))?. - Panic policy is enforced by lints (
clippy::unwrap_usedandclippy::panicdenied in both main crates) and mitigated at runtime: a custom hook restores the terminal before printing, so a crash never leaves the user's shell in raw mode (extras/gitui/src/main.rs):
panic::set_hook(Box::new(|e| {
let backtrace = Backtrace::new();
shutdown_terminal();Normal shutdown uses scopeguard::defer! { shutdown_terminal(); } immediately after terminal setup. The only explicit exit code is std::process::exit(0) after --bugreport output in extras/gitui/src/args.rs; all other paths exit through Result.
- Builder pattern:
SignBuilder::from_gitconfigreturns aBox<dyn Sign>selected from git config, withimpl Sign for GPGSignandimpl Sign for SSHSignas concrete strategies. - Newtypes:
CommitId(Oid)in extras/gitui/asyncgit/src/sync/commits_info.rs wraps the raw git2 object id and centralizes every conversion (From<Oid>,From<gix::ObjectId>,From<gix::Commit<'_>>,Display), letting the UI crate stay ignorant of both Git backends.RepoPathin extras/gitui/asyncgit/src/sync/repository.rs is an enum newtype distinguishing a plain path from a separated gitdir/workdir pair, withFrom<PathBuf>andFrom<&str>for ergonomic construction. - Visibility discipline: asyncgit's
lib.rsre-exports a curatedsyncAPI while keeping job modules (fetch_job,filter_commits) private;#![forbid(missing_docs)]forces every public item to be documented or hidden.
-
Trait-object component architecture. extras/gitui/src/components/mod.rs defines
Component(event handling, command reporting) andDrawableComponent(rendering), and generic pumps that fan events through&mut [&mut dyn Component]:event_pumpreturnsResult<EventState>and stops at the first consumer, whilecommand_pumprespectsCommandBlocking::Blockingto scope the help bar to the focused component. -
Declarative macros to keep component lists exhaustive. The
accessors!macro in the same file generates matchedcomponents()andcomponents_mut()vectors from one identifier list, andsetup_popups!composesany_popup_visible!anddraw_popups!, so adding a popup in one place updates visibility checks, drawing, and event routing together. -
Generic async job abstraction with associated types. extras/gitui/asyncgit/src/asyncjob/mod.rs:
pub trait AsyncJob: Send + Sync + Clone { /// defines what notification type is used to communicate outside type Notification: Copy + Send; /// type of progress type Progress: Clone + Default + Send + Sync + PartialEq;
AsyncSingleJob<J: AsyncJob>implements a one-slot queue that keeps overwritingnextuntil the worker takes it, which is exactly the right semantics for a UI that only cares about the latest requested diff. -
Channel multiplexing with
crossbeam_channel::Select.select_eventin extras/gitui/src/main.rs registers six receivers (input, git notifications, app notifications, ticker, watcher, spinner) and maps the ready operation index into aQueueEvent, giving a single-threaded event loop over many producers without async runtimes. -
A purpose-built synchronization primitive. extras/gitui/src/notify_mutex.rs defines
NotifiableMutex<T>combiningArc<(Mutex<T>, Condvar)>withwait(condition)andset_and_notify(value), used to park the input thread cheaply while the UI is suspended. -
Bitflags as render dirty-flags. extras/gitui/src/queue.rs declares
NeedsUpdatewithbitflags!(ALL,DIFF,COMMANDS, ...) so internal events can request the minimal redraw work. -
Zero-copy with
Cow. extras/gitui/src/strings.rs:pub fn ellipsis_trim_start(s: &str, width: usize) -> Cow<'_, str> { if s.width() <= width { Cow::Borrowed(s) } else {
The common case borrows; only over-wide strings allocate.
Vec<Cow<'a, str>>also backs wrapped commit messages in extras/gitui/src/components/commit_details/details.rs. -
Hand-written lifetime-carrying iterators. extras/gitui/filetreelist/src/treeitems_iter.rs implements
Iterator for TreeItemsIterator<'a>withtype Item = (usize, &'a FileTreeItem), yielding only visible items of a folded tree without allocating, and extras/gitui/asyncgit/src/sync/sign.rs shows idiomatic pipeline style (lines().filter_map(|line| line.strip_prefix("fpr:")).find_map(...)) for parsing gpgsm output. -
Deliberate interior-mutability split. The single-threaded UI uses
Rc<RefCell<Options>>andcmdbar: RefCell<CommandBar>(extras/gitui/src/app.rs) plus the aliaspub type RepoPathRef = RefCell<RepoPath>(extras/gitui/asyncgit/src/sync/repository.rs), while everything crossing the threadpool boundary in asyncjob usesArc<Mutex<...>>andArc<RwLock<Progress>>. Cheap where possible, synchronized only where required. -
Unsafe policy: forbid by default, allow surgically.
#![forbid(unsafe_code)]guards the binary, scopetime, and git2-hooks; the only two unsafe sites in the whole workspace are the git2set_search_pathsandboxing in extras/gitui/git2-testing/src/lib.rs (behind#[allow(unsafe_code)]on one function, with a provenance comment) and the intentional invalid-UTF-8 constructor in extras/gitui/invalidstring/src/lib.rs. -
Lossless numeric conversion instead of
as. Theeasy-castcrate'sCasttrait is used at UI boundaries, e.g.x += Cast::<u16>::cast(symbol.width());in extras/gitui/src/ui/stateful_paragraph.rs, and its failure mode is integrated into the error enum (EasyCast(#[from] easy_cast::Error)in extras/gitui/asyncgit/src/error.rs). -
Feature-compiled instrumentation with RAII. extras/gitui/scopetime/src/lib.rs implements
Drop for ScopeTimeLog<'_>to log elapsed time, and exports two versions ofscope_time!: the real one under#[cfg(feature = "enabled")]and an emptymacro_rules! scope_time { ($target:literal) => {}; }otherwise, so instrumentation costs zero in normal builds yet stays syntactically valid everywhere. -
Platform
cfghandling at function granularity. extras/gitui/src/clipboard.rs selectspbcopyunder#[cfg(target_os = "macos")],clip.exeunder#[cfg(windows)], and probes wl-copy/xclip/xsel viawhichelsewhere; unix-only tests are gated#[cfg(unix)](extras/gitui/asyncgit/src/sync/sign.rs) and one hooks test is#[cfg(target_os = "linux")](extras/gitui/asyncgit/src/sync/hooks.rs). -
Derive-powered partial configuration. Keybindings are a plain struct with
#[derive(Debug, Clone, Patch)]and#[patch(attribute(derive(Deserialize, Debug)))]fromstruct-patch(extras/gitui/src/keys/key_list.rs); user RON files deserialize into the generated patch type and are applied over defaults withkeys_list.apply(patch), so a config file only ever needs to mention the keys it overrides (a full example ships as extras/gitui/vim_style_key_config.ron). -
Ergonomic enum conversions instead of bare booleans.
EventStatein extras/gitui/src/components/mod.rs replaces aboolreturn with a named two-variant enum and suppliesimpl From<bool> for EventStateplus anis_consumed()accessor, so event handlers read as intent (Ok(true.into())at call sites,if c.event(ev)?.is_consumed()in the pump) and cannot be accidentally inverted. The same file models help-bar propagation asCommandBlocking::{Blocking, PassingOn}rather than a boolean flag. -
Wrapper types to bridge foreign traits.
GituiKeyEventin extras/gitui/src/keys/key_list.rs wrapscrossterm::event::KeyEvent's fields so the project can deriveSerialize/Deserializeandstruct-patchsupport on key bindings, withFrom<&GituiKeyEvent> for KeyEventconversions and a customPartialEqthat compares through the canonical crossterm representation, keeping serialization concerns out of the vendor type.
- Crate docs double as architecture docs. extras/gitui/src/main.rs opens with a
//!map of the module groups (tabs, components, popups, ui, asyncgit) and of the included crates with their dependency relationships. extras/gitui/src/components/mod.rs documents the composition philosophy explicitly, including its limits ("composition is driven by code", plus an honest note that the two traits should probably merge someday). - asyncgit enforces docs with
#. The team consciously trades prose for coverage: many items carry an empty///doc, andclippy::empty_docsis allowed, meaning the forbid acts as a checklist that makes undocumented surface impossible while letting trivial items stay terse. - User docs are versioned markdown at the repo root: extras/gitui/KEY_CONFIG.md (custom keybindings), extras/gitui/THEMES.md (theme RON patching), extras/gitui/FAQ.md, extras/gitui/NIGHTLIES.md (nightly artifact URLs), and a 301-line README with a linked table of contents and a per-package-manager install matrix.
- extras/gitui/CONTRIBUTING.md is short and welcoming: build instructions by reference, a Discord link for help, and a pointer to
good-first-issuelabels. - extras/gitui/.github/PULL_REQUEST_TEMPLATE.md encodes the quality gate as a checklist:
I followed the checklist:
- [ ] I added unittests
- [ ] I ran `make check` without errors
- [ ] I tested the overall application
- [ ] I added an appropriate item to the changelog- Issue templates exist for bug reports and feature requests (extras/gitui/.github/ISSUE_TEMPLATE/bug_report.md, feature_request.md), and the in-app
--bugreportflag (extras/gitui/src/bug_report.rs, built on thebugreportcrate) prints version, OS, compile-time info, and relevant environment variables as Markdown ready to paste into an issue.
- Versioning is SemVer with the binary and asyncgit released in lockstep at 0.28.1 (extras/gitui/Cargo.toml, extras/gitui/asyncgit/Cargo.toml); utility crates version independently (filetreelist 0.6.0, git2-hooks 0.7.0).
- Changelog discipline is strict Keep a Changelog: extras/gitui/CHANGELOG.md (1,025 lines) keeps an
## Unreleasedsection that every PR must append to (enforced socially by the PR template and mechanically by thelog-testCI job that extracts release notes from it on every run). Entries credit contributors by handle and link issues, and release sections embed screenshots of headline features. - The release pipeline is tag-driven (extras/gitui/.github/workflows/cd.yml): artifacts are mac arm64 and x86 tarballs, a musl-static Linux x86_64 tarball, aarch64/armv7/arm tarballs, a Windows tarball, and a WiX MSI (sources in extras/gitui/wix/main.wxs). Makefile release targets strip binaries and print
otool -Lso accidental dynamic linkage is visible in logs. Release bodies come from the changelog viaffurrer2/extract-release-notes@v2; hyphenated tags publish as prereleases; a successful stable release auto-bumps homebrew-core. - Reproducibility and provenance: extras/gitui/build.rs honors
SOURCE_DATE_EPOCHfor the build date, acceptsBUILD_GIT_COMMIT_IDforgit archivetarballs, and stampsGITUI_BUILD_NAMEas either the bare version (whenGITUI_RELEASE=1) or<version>-nightly <date> (<hash>), whichclapthen surfaces via.version(env!("GITUI_BUILD_NAME"))in extras/gitui/src/args.rs. - A parallel nightly channel (extras/gitui/.github/workflows/nightly.yml) rebuilds all platforms daily and pushes to S3, giving users a low-friction way to verify fixes before a release.
- gitui is a flag-only CLI (no subcommands), and the repository ships no shell completions or man pages; discoverability is delegated to the in-app help and
--helptemplate defined in extras/gitui/src/args.rs. - License compliance for distributors is one command away: the Makefile's
licensestarget runscargo bundle-licenses --format toml --output THIRDPARTY.toml(extras/gitui/Makefile), producing a machine-readable third-party license inventory that packagers can regenerate at any tag. - Local packaging parity: the same Makefile targets CI uses (
release-mac,release-win,release-linux-musl) are runnable on a developer machine, so a maintainer can reproduce any release artifact without GitHub Actions, andinstall/install-timingtargets exercise the exactcargo install --path "." --offline --lockedpath users hit.
quinjet already matches gitui on rustfmt, cargo-deny, typos, taplo-style TOML checking, and a stricter clippy wall. The practices still worth importing, with mechanisms:
- Adopt cargo-nextest as the test runner:
cargo nextest run --workspacein the Makefile andtaiki-e/install-action@nextestin CI, plus filter expressions (-E 'not test(name)') for environment-dependent exclusions, as in extras/gitui/Makefile. - Add full-TUI snapshot tests: drive the ratatui app with
ratatui::backend::TestBackend, assert frames withinsta::assert_snapshot!, and normalize temp paths and commit hashes withinsta::Settingsfilters (features = ["filters"]), mirroring extras/gitui/src/gitui.rs and extras/gitui/src/snapshots/. - Sandbox Git global config in every test: call
git2::opts::set_search_pathfor System/Global/XDG/ProgramData to a temp dir inside astd::sync::Once, as extras/gitui/git2-testing/src/lib.rs does, so a developer's.gitconfigcan never change test results. - Pin the MSRV three times:
rust-versionin Cargo.toml,msrvin.clippy.toml, and a literal MSRV row in the CI matrix withcontinue-on-erroronly on the nightly row (extras/gitui/.github/workflows/ci.yml). - Add a
cargo install --path . --force --lockedCI step: it catches lockfile drift and packaging breakage that plaincargo buildmisses. - Add a
cargo-udepsjob on the nightly toolchain (cargo +nightly udeps --all-targets) to keep the dependency list honest. - Enforce changelog extractability in CI: Keep a Changelog format plus a job running
ffurrer2/extract-release-notes@v2on every PR, then reuse the same extraction for the GitHub release body in the tag-triggered workflow (extras/gitui/.github/workflows/cd.yml). - Group dependabot cargo updates with
groups:keyed onupdate-typesminor/patch (extras/gitui/.github/dependabot.yml) to collapse update noise. - Install a panic hook that restores the terminal before printing, capture a
backtrace::Backtrace, and pair it withscopeguard::defer!for the normal shutdown path (extras/gitui/src/main.rs); for a TUI this is the difference between a readable crash report and a corrupted shell. - Ship a
--bugreportflag using thebugreportcrate withSoftwareVersion,OperatingSystem,CompileTimeInformation, and selectedEnvironmentVariablescollectors printed as Markdown (extras/gitui/src/bug_report.rs). - Stamp rich version strings from
build.rs: embed short git hash and build date into an env var consumed by clap, honorSOURCE_DATE_EPOCHfor reproducible builds, and gate release naming on an env flag as extras/gitui/build.rs does withGITUI_RELEASE. - Add feature-gated scope timing: a
scope_time!("label")RAII macro that logs elapsed milliseconds and compiles to nothing without thetimingfeature (extras/gitui/scopetime/src/lib.rs), plus amake profiletarget wrappingcargo flamegraph. - Turn on
multiple-versions = "deny"in deny.toml[bans], documenting eachskip-treeexception with the responsible crate and upstream issue link, following extras/gitui/deny.toml. - Speed up debug iteration with
[profile.dev.package."ratatui"] opt-level = 3and shrink releases withopt-level = "z",lto = true,codegen-units = 1,strip = "debuginfo"(extras/gitui/Cargo.toml). - Use
Swatinem/rust-cache@v2with ashared-keyof${{ matrix.os }}-${{ env.cache-name }}-${{ matrix.rust }}so cache entries are correctly partitioned per OS and toolchain. - Support partial user config via
struct-patch: derivePatchon the keybinding and options structs and apply deserialized RON patches over defaults (extras/gitui/src/keys/key_list.rs), so user files only state deltas. - Encode the contribution gate in
.github/PULL_REQUEST_TEMPLATE.mdas a checklist referencing the repo's ownmake checkaggregate target (extras/gitui/.github/PULL_REQUEST_TEMPLATE.md). - If distribution matters, copy the release lattice: musl-static Linux binary (
--target x86_64-unknown-linux-muslwithmusl-tools), prerelease detection viacontains(github.ref, '-'), and a scheduled nightly artifact channel (extras/gitui/.github/workflows/nightly.yml).
Generated from docs/, edit the docs in the repo, not the wiki.
CLI reference
Pull Request
- View
- Commits
- Files
- Diff
- Conversation
- Checks
- Logs
- Open
- Merge
- Admin Merge
- Auto Merge
- Disable Auto Merge
- Dequeue
- Ready
- Draft
- Review
- Reviews
- Comment
- Edit Last Comment
- Delete Last Comment
- Edit
- Update Branch
- Lock
- Unlock
- Subscribe
- Unsubscribe
- Allow Maintainer Edits
- Disallow Maintainer Edits
- Revert
- Close
- Reopen
Guides
Optimization
Rust practices