use serde::{Deserialize, Serialize};
use super::builder::RebuildOutcome;
use super::fts::FtsScope;
use crate::git::CommitInfo;
use crate::path::RelPath;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "op", content = "args", rename_all = "snake_case")]
pub enum GitHistoryOp {
Sync,
IndexedHead,
RecentCommits {
skip: usize,
take: usize,
include_files: bool,
},
CommitsTouching { path: RelPath, skip: usize, take: usize },
WindowCommits { window: usize },
SearchCommits {
query: String,
scope: FtsScope,
skip: usize,
take: usize,
},
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "reply", content = "data", rename_all = "snake_case")]
pub enum GitHistoryReply {
Synced(SyncOutcome),
IndexedHead(Option<String>),
Commits(Vec<CommitInfo>),
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "outcome", content = "data", rename_all = "snake_case")]
pub enum SyncOutcome {
Fresh,
Incremental { added: u32 },
FullRebuild { reason: String, commits: u32 },
}
impl From<RebuildOutcome> for SyncOutcome {
fn from(outcome: RebuildOutcome) -> Self {
match outcome {
RebuildOutcome::Fresh => SyncOutcome::Fresh,
RebuildOutcome::Incremental { added } => SyncOutcome::Incremental { added },
RebuildOutcome::FullRebuild { reason, commits } => SyncOutcome::FullRebuild {
reason: reason.to_string(),
commits,
},
}
}
}