last_git_commit/
lib.rs

1/// ! Get information about the last git commit, such as
2/// ! git hash, author and time. Please see take a look at
3/// ! the [examples] as they probably provide better docs
4/// ! than this!
5/// !
6/// ! [examples]: https://github.com/olback/lgc-rs/tree/master/examples
7
8use std::path::PathBuf;
9
10mod author;
11mod id;
12mod builder;
13use builder::LastGitCommitBuilder;
14
15pub struct LastGitCommit {
16    path: PathBuf,
17    branch: String,
18    message: Option<String>,
19    author: author::Author,
20    id: id::Id,
21    timestamp: i64
22}
23
24impl LastGitCommit {
25
26    /// Create new builder
27    pub fn new() -> LastGitCommitBuilder {
28
29        LastGitCommitBuilder::new()
30
31    }
32
33    /// Get path
34    pub fn path(&self) -> &PathBuf {
35
36        &self.path
37
38    }
39
40    /// Get branch
41    pub fn branch(&self) -> &String {
42
43        &self.branch
44
45    }
46
47    /// Get commit message
48    pub fn message(&self) -> Option<&String> {
49
50        self.message.as_ref()
51
52    }
53
54    /// Get commit author
55    pub fn author(&self) -> &author::Author {
56
57        &self.author
58
59    }
60
61    /// Get commit id (hash)
62    pub fn id(&self) -> &id::Id {
63
64        &self.id
65
66    }
67
68    /// Get commit timestamp
69    pub fn timestamp(&self) -> i64 {
70
71        self.timestamp
72
73    }
74
75}