Skip to main content

fallow_config/
lib.rs

1#![cfg_attr(
2    test,
3    allow(
4        clippy::unwrap_used,
5        clippy::expect_used,
6        reason = "tests use unwrap and expect to keep fixture setup concise"
7    )
8)]
9
10mod config;
11mod config_writer;
12mod external_plugin;
13mod fixability;
14mod jsonc;
15pub mod levenshtein;
16mod rule_pack;
17mod workspace;
18
19pub use config::*;
20pub use config_writer::*;
21pub use external_plugin::*;
22pub use fixability::*;
23pub use rule_pack::*;
24pub use workspace::*;
25
26use std::path::{Path, PathBuf};
27
28/// Basename of the local walkthrough viewed-state ledger inside the cache dir.
29const WALKTHROUGH_STATE_FILE: &str = "walkthrough-state.json";
30
31/// Path to the local `fallow review --walkthrough` viewed-state ledger inside a
32/// resolved cache directory (default `<root>/.fallow`, already gitignored).
33///
34/// Pure path join, mirroring the `cache.bin` / `graph-cache.bin` / `churn.bin`
35/// conventions; the file IO and serde live in the CLI crate to keep this crate
36/// free of side effects.
37#[must_use]
38pub fn walkthrough_state_path(cache_dir: &Path) -> PathBuf {
39    cache_dir.join(WALKTHROUGH_STATE_FILE)
40}
41
42#[cfg(test)]
43mod walkthrough_state_path_tests {
44    use super::walkthrough_state_path;
45    use std::path::Path;
46
47    #[test]
48    fn joins_state_file_under_cache_dir() {
49        let path = walkthrough_state_path(Path::new("/project/.fallow"));
50        assert_eq!(path, Path::new("/project/.fallow/walkthrough-state.json"));
51    }
52}