1use chrono::{DateTime, Local};
6
7#[derive(Debug, Clone)]
9pub struct CompareCommit {
10 pub hash: String,
12 pub message: String,
14 pub author: String,
16 pub date: DateTime<Local>,
18}
19
20#[derive(Debug, Clone)]
22pub struct BranchCompare {
23 pub base_branch: String,
25 pub target_branch: String,
27 pub ahead_commits: Vec<CompareCommit>,
29 pub behind_commits: Vec<CompareCommit>,
31 pub merge_base: String,
33}
34
35impl BranchCompare {
36 pub fn total_commits(&self) -> usize {
38 self.ahead_commits.len() + self.behind_commits.len()
39 }
40
41 pub fn is_synced(&self) -> bool {
43 self.ahead_commits.is_empty() && self.behind_commits.is_empty()
44 }
45}
46
47#[derive(Debug, Clone, Copy, PartialEq, Default)]
49pub enum CompareTab {
50 #[default]
51 Ahead,
52 Behind,
53}
54
55impl CompareTab {
56 pub fn toggle(&self) -> Self {
58 match self {
59 CompareTab::Ahead => CompareTab::Behind,
60 CompareTab::Behind => CompareTab::Ahead,
61 }
62 }
63}