1pub mod deps;
2pub mod history;
3pub mod retrieve;
4pub mod summary;
5
6use crate::error::{ChronicleError, Result};
7use crate::git::GitOps;
8use crate::schema::annotation::{LineRange, RegionAnnotation};
9
10#[derive(Debug, Clone)]
12pub struct ReadQuery {
13 pub file: String,
14 pub anchor: Option<String>,
15 pub lines: Option<LineRange>,
16}
17
18#[derive(Debug, Clone, serde::Serialize)]
20pub struct ReadResult {
21 pub file: String,
22 pub regions: Vec<MatchedRegion>,
23}
24
25#[derive(Debug, Clone, serde::Serialize)]
27pub struct MatchedRegion {
28 pub commit: String,
29 pub timestamp: String,
30 pub region: RegionAnnotation,
31 pub summary: String,
32}
33
34pub fn execute(git: &dyn GitOps, query: &ReadQuery) -> Result<ReadResult> {
36 let regions = retrieve::retrieve_regions(git, query).map_err(|e| ChronicleError::Git {
37 source: e,
38 location: snafu::Location::default(),
39 })?;
40
41 Ok(ReadResult {
42 file: query.file.clone(),
43 regions,
44 })
45}