File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 1010) ]
1111
1212use anyhow:: { Context , Result } ;
13+ use codeprints_analyzer:: git;
14+ use codeprints_analyzer:: Merger ;
1315use codeprints_analyzer:: Parser ;
1416use codeprints_analyzer:: Timeline ;
15- use codeprints_analyzer:: { count_commits, Merger } ;
1617use glob:: glob;
1718use std:: fs;
1819use structopt:: StructOpt ;
@@ -39,7 +40,7 @@ fn main() -> Result<()> {
3940 committer,
4041 } => {
4142 print ! ( "Analyzing commits in current repository..." ) ;
42- let input = count_commits ( & before, & after, author, committer) . context (
43+ let input = git :: count_commits ( & before, & after, author, committer) . context (
4344 "Cannot read project history. Make sure there is no typo in the command" ,
4445 ) ?;
4546 let mut parser = Parser :: new ( input) ;
@@ -51,7 +52,8 @@ fn main() -> Result<()> {
5152 }
5253 let timeline = parser. parse ( ) ?;
5354
54- write ( & timeline, "codeprints.json" ) ?;
55+ let sha = git:: sha ( ) ?;
56+ write ( & timeline, & format ! ( "codeprints_{}.json" , sha) ) ?;
5557 }
5658 Command :: Merge { } => {
5759 // Find all `codeprints*.json` files in the current directory
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ pub fn count_commits(
3030 Ok ( commits)
3131}
3232
33- // Parse a date from the git log
33+ /// Parse a date from the git log
3434pub fn parse_date ( line : & str ) -> Result < Option < NaiveDate > > {
3535 if line. trim ( ) . is_empty ( ) {
3636 // Empty lines are allowed, but skipped
@@ -39,3 +39,9 @@ pub fn parse_date(line: &str) -> Result<Option<NaiveDate>> {
3939 let date: NaiveDate = line. parse ( ) . context ( format ! ( "Invalid date {}" , line) ) ?;
4040 Ok ( Some ( date) )
4141}
42+
43+ /// Get the current git commit sha
44+ pub fn sha ( ) -> Result < String > {
45+ let sha = cmd ( "git" , & [ "rev-parse" , "--short" , "HEAD" ] ) . read ( ) ?;
46+ Ok ( sha)
47+ }
Original file line number Diff line number Diff line change 1212 unused_qualifications
1313) ]
1414
15- mod git;
15+ /// Git helper functions
16+ pub mod git;
17+
1618mod merge;
1719mod parser;
1820mod quartiles;
1921mod types;
2022
21- pub use crate :: git:: count_commits;
2223pub use crate :: merge:: Merger ;
2324pub use crate :: parser:: Parser ;
24- pub use crate :: types:: Timeline as Timeline ;
25+ pub use crate :: types:: Timeline ;
You can’t perform that action at this time.
0 commit comments