aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcs/mod.rs
blob: 02c2eb74b8bc975da3f273fdbecb8efefc6fecf6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
mod git;

pub enum VcsType {
    Git,
}

#[derive(Debug,Copy,Clone)]
pub enum ActiveOperation {
    None,
    Merge,
    Revert,
    CherryPick,
    Bisect,
    Rebase,
}

pub trait VcsInfo {
    fn vcs(&self) -> VcsType;
    fn has_modified_files(&self) -> bool;
    fn has_staged_files(&self) -> bool;
    fn has_new_files(&self) -> bool;
    fn has_commits(&self) -> bool;
    fn active_operation(&self) -> ActiveOperation;
    fn branch(&self) -> Option<String>;
    fn remote_branch_diff(&self) -> Option<(usize, usize)>;
}

pub fn detect() -> Option<Box<VcsInfo>> {
    if let Some(git) = git::detect() {
        Some(git)
    }
    else {
        None
    }
}