Skip to content

Commit

Permalink
feat(history): make history works
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 4, 2021
1 parent f7a6b55 commit e01ec73
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
12 changes: 10 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ lazy_static = "1.4.0"
chrono = "0.4"

git2 = "0.13"
git-scanner = "0.1.3"
git-scanner = "0.1.4"

# for cli usage
clap = "2.33.3"
Expand Down
27 changes: 19 additions & 8 deletions src/infrastructure/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ mod test {
use crate::infrastructure::git::git_log_parser::GitMessageParser;
use crate::infrastructure::git::GitRepository;
use core_model::url_format;
use git_scanner::git::GitCalculator;
use git_scanner::git_logger::GitLogConfig;
use git_scanner::{file_walker, IndicatorCalculator};

static INIT: Once = Once::new();

Expand Down Expand Up @@ -95,17 +98,25 @@ mod test {
fn should_get_file_history() {
initialize();

let local_path = url_format::uri_to_path("https://github.com/coco-rs/coco.fixtures");
let root = url_format::uri_to_path("https://github.com/coco-rs/coco.fixtures");

let mut tics: Vec<Box<dyn IndicatorCalculator>> = vec![];
let calculator = Box::new(GitCalculator::new(
GitLogConfig::default().include_merges(true).since_years(3),
true,
));

use git_scanner::indicator_calculator::IndicatorCalculator;
tics.push(calculator);

let mut calculator = git_scanner::scanner_by_years(3);
let result = calculator.calculate(&local_path);
match result {
Ok(some) => {
println!("{:?}", some.unwrap());
let mut tree = file_walker::walk_directory(&root, &mut tics).unwrap();

for tic in tics {
if let Some(metadata) = tic.metadata().unwrap() {
tree.add_data(tic.name() + "_meta", metadata);
}
Err(_) => {}
}

let output = serde_json::to_string(&tree).unwrap();
println!("{:?}", output);
}
}

0 comments on commit e01ec73

Please sign in to comment.