forked from gitui-org/gitui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.rs
45 lines (39 loc) · 806 Bytes
/
state.rs
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
36
37
38
39
40
41
42
43
44
45
use super::RepoPath;
use crate::{error::Result, sync::repository::repo};
use git2::RepositoryState;
use scopetime::scope_time;
///
#[derive(Debug, PartialEq, Eq)]
pub enum RepoState {
///
Clean,
///
Merge,
///
Rebase,
///
Revert,
///
Other,
}
impl From<RepositoryState> for RepoState {
fn from(state: RepositoryState) -> Self {
match state {
RepositoryState::Clean => Self::Clean,
RepositoryState::Merge => Self::Merge,
RepositoryState::Revert => Self::Revert,
RepositoryState::RebaseMerge => Self::Rebase,
_ => {
log::warn!("state not supported yet: {:?}", state);
Self::Other
}
}
}
}
///
pub fn repo_state(repo_path: &RepoPath) -> Result<RepoState> {
scope_time!("repo_state");
let repo = repo(repo_path)?;
let state = repo.state();
Ok(state.into())
}