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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use git;
use report;
use output;
use commit;
use config;
use exitcode;
pub fn run(config: &config::Configuration, given_range: Option<Vec<String>>) -> exitcode::ExitCode {
if git::in_git_repository().is_err() {
return exitcode::NOINPUT;
}
let range = match given_range {
Some(vec) => vec,
None => {
let from = match git::last_tag() {
Ok(Some(tag)) => tag,
_ => {
warn!("No tags found, using HEAD^");
String::from("HEAD^")
}
};
let to = String::from("HEAD");
vec![format!("^{}", from), to]
}
};
info!("Using revision range {}", range.join(" "));
let hashes = git::commits_in_range(&range);
if hashes.is_err() {
error!("No commits in range. {:?}", hashes);
return exitcode::NOINPUT;
}
let mut commits = Vec::new();
for sha in hashes.unwrap() {
let message = git::get_commit_message(&sha);
if message.is_err() {
warn!("Commit {} could not be read. {:?}", sha, message);
continue;
}
let commit = commit::parse(&message.unwrap(), &config.date_format);
if config::is_interesting(config, &commit) {
commits.push(commit);
}
}
commits.sort_by(|a, b| a.time.cmp(&b.time));
let report = report::generate(config, &commits);
output::render(config, &report);
exitcode::OK
}