| 1 | //! `df-index` — reconstruction of jj semantics from pushed Git objects. |
| 2 | //! |
| 3 | //! Dogfood never runs the `jj` binary. A `jj git push` is an ordinary Git push; |
| 4 | //! this crate reads jj's metadata back out of the pushed commit objects and |
| 5 | //! turns it into the change index the product is built on. |
| 6 | //! |
| 7 | //! The crate is deliberately free of any Git library dependency. Everything |
| 8 | //! here operates on raw bytes and plain data, which keeps `gix` confined to |
| 9 | //! `df-store` (spec §3 rule 1) and makes the format-sensitive logic testable |
| 10 | //! against byte literals captured from real repositories. |
| 11 | |
| 12 | pub mod change_id; |
| 13 | pub mod indexer; |
| 14 | pub mod synthetic; |
| 15 | |
| 16 | pub use change_id::{ |
| 17 | extract_change_id, extract_conflict_trees, is_conflict_artifact, ChangeId, ConflictTrees, |
| 18 | }; |
| 19 | pub use indexer::{line_map, rebase_anchor, stack_edges, AnchorOutcome, IndexedCommit, NewLine, StackEdge}; |
| 20 | pub use synthetic::{normalise_diff, synthetic_change_id, PatchIdentity, SyntheticId}; |
| 21 | |
| 22 | /// The identity assigned to an indexed commit. |
| 23 | /// |
| 24 | /// Every commit gets one. Which variant it is determines whether the UI shows a |
| 25 | /// change chip and how much revision history Dogfood can promise (spec §4). |
| 26 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 27 | pub enum Identity { |
| 28 | /// A real jj change id, read from the commit's `change-id` header. |
| 29 | Change(ChangeId), |
| 30 | /// A patch-derived identity for a commit authored by plain git. |
| 31 | Synthetic(SyntheticId), |
| 32 | } |
| 33 | |
| 34 | impl Identity { |
| 35 | /// The canonical string stored in `changes.change_id`. |
| 36 | pub fn as_str(&self) -> &str { |
| 37 | match self { |
| 38 | Identity::Change(c) => c.as_str(), |
| 39 | Identity::Synthetic(s) => s.as_str(), |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /// Whether this identity is synthesised rather than authored by jj. |
| 44 | /// Maps directly to `changes.synthetic`. |
| 45 | pub fn is_synthetic(&self) -> bool { |
| 46 | matches!(self, Identity::Synthetic(_)) |
| 47 | } |
| 48 | } |
48 lines · Rust