use serde::{Deserialize, Serialize};

use crate::cmd::oid::ObjectId;

pub mod blame_file;
pub mod blame_hunk;
pub mod blame_line;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommitBlameHunk {
    pub commit_oid: ObjectId,
    pub final_start_line: u32,
    pub final_lines: u32,
    pub orig_start_line: u32,
    pub orig_lines: u32,
    pub boundary: bool,
    pub orig_path: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommitBlameLine {
    pub commit_oid: ObjectId,
    pub line_no: u32,
    pub content: String,
    pub orig_path: Option<String>,
}

#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct BlameOptions {
    pub min_line: Option<usize>,
    pub max_line: Option<usize>,
    pub track_copies_same_file: bool,
    pub track_copies_same_commit_moves: bool,
    pub ignore_whitespace: bool,
}

impl BlameOptions {
    pub fn new() -> Self {
        Self::default()
    }

    pub fn min_line(mut self, line: usize) -> Self {
        self.min_line = Some(line);
        self
    }

    pub fn max_line(mut self, line: usize) -> Self {
        self.max_line = Some(line);
        self
    }
    pub fn track_copies_same_file(mut self) -> Self {
        self.track_copies_same_file = true;
        self
    }

    pub fn track_copies_same_commit_moves(mut self) -> Self {
        self.track_copies_same_commit_moves = true;
        self
    }

    pub fn ignore_whitespace(mut self) -> Self {
        self.ignore_whitespace = true;
        self
    }
}
