facett-git 0.1.12

facett — git repository facet: browse branches, commit log, the file tree, and syntax-coloured source, all clickable. gix-backed (optional feature), egui-rendered. A consumer (nornir) drops it in to show git for any repo.
Documentation
# facett-git

> A facett **git repository facet** — browse branches, the commit log, the file
> tree, and **syntax-coloured source**, all clickable, in any egui app.

`facett-git` implements the facett [`Facet`] contract, so a consumer (e.g. nornir's
viz) drops it into a `FacetDeck` and gets a live git browser plus headless
robot-testing for free.

```text
┌── Branches ──┬── Tree / Log ──┬──────── Source ────────────┐
│ ● main a1b2c │ 📁 src         │ fn main() {                │   ← fn/let = keyword
│   feature 0f │ 📄 Cargo.toml  │     let x = 42;  // hi     │   ← 42 = number
│              │ 📄 README.md   │ }                          │   ← // hi = comment
└──────────────┴────────────────┴────────────────────────────┘
```

## What it does

- **Branches** — every local branch with its tip; the checked-out one is marked.
- **Commit log** — id · summary · author, walked from `HEAD`.
- **File tree** — directories first, click to select.
- **Source pane** — a file rendered with a deterministic pure-Rust syntax
  highlighter (keywords, types, strings, comments, numbers, attributes) into an egui
  `LayoutJob`. egui *can* render coloured Rust text — this is how.

## Two data paths

| Path | Needs git? | Use |
|---|---|---|
| `GitView::new(snapshot)` | no | host supplies a `RepoSnapshot` (+ a `Blob`) |
| `GitView::open(path, max)` | yes — `gix` feature | read a repo live off disk |

The pure `RepoSnapshot` model is always available and `serde`-serializable, so the
crate **builds and tests with no git dependency**. The live reader is gated behind
the optional `gix` feature (matching the sibling nornir's `gix` 0.84).

```rust
use facett_git::GitView;

// host-supplied data (no git dependency)
let view = GitView::demo();

// or read a repo live (requires `features = ["gix"]`)
# #[cfg(feature = "gix")]
let view = GitView::open("/path/to/repo", 100)?;
# #[cfg(feature = "gix")] Ok::<(), String>(())
```

Render coloured code anywhere with the same highlighter:

```rust
use facett_git::GitView;
let job = GitView::highlight_job("fn x() -> u32 { 7 }", &Default::default(),
                                 egui::FontId::monospace(12.0));
// ui.label(job);
```

## Contract & determinism

Implements `Facet` — `title` / `ui` / `state_json` — and advertises
`scalable · selectable · themeable` caps. Everything visible (branch/commit/tree
counts, selection, open path, pane) is in `state_json` for headless assertions
(LAW 6), and the highlighter is **deterministic** (FC-7): identical source → identical
spans.

## Features

- `default` — pure facet + highlighter, no git dep.
- `gix` — the live on-disk repository reader (`RepoSnapshot::open`).
- `testmatrix` — functional-status emitter passthrough.

## Tests

```sh
cargo test -p facett-git           # pure facet + highlighter (9 tests)
cargo test -p facett-git --features gix
```

Covered: the highlighter tiles every byte / classifies each token kind /
is deterministic / empty-is-empty; the snapshot model is well-formed and serde
round-trips; the `Facet` `state_json` exposes counts + selection, scale clamps, and
the highlight job actually colours the `fn` keyword differently from plain text.

## License

MIT OR Apache-2.0.

[`Facet`]: https://codeberg.org/nordisk/facett