git_info/
types.rs

1//! # types
2//!
3//! Public library types.
4//!
5
6#[cfg(test)]
7#[path = "./types_test.rs"]
8mod types_test;
9
10use std::collections::HashMap;
11
12#[derive(Debug, Clone, Default)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14/// Holds git head info
15pub struct Head {
16    /// The last commit hash
17    pub last_commit_hash: Option<String>,
18    /// The last commit hash short prefix
19    pub last_commit_hash_short: Option<String>,
20}
21
22impl Head {
23    /// Returns new instance
24    pub fn new() -> Head {
25        Default::default()
26    }
27}
28
29#[derive(Debug, Clone, Default)]
30#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
31/// Holds git info for the given repo directory
32pub struct GitInfo {
33    /// User name
34    pub user_name: Option<String>,
35    /// User email
36    pub user_email: Option<String>,
37    /// True if there are non commited changes
38    pub dirty: Option<bool>,
39    /// Current branch name
40    pub current_branch: Option<String>,
41    /// All branch names
42    pub branches: Option<Vec<String>>,
43    /// Head information
44    pub head: Head,
45    /// Config key/value map
46    pub config: Option<HashMap<String, String>>,
47}
48
49impl GitInfo {
50    /// Returns new instance
51    pub fn new() -> GitInfo {
52        Default::default()
53    }
54}