Skip to content

Commit

Permalink
feat: make commit config pass to cli analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 16, 2021
1 parent c3d1c64 commit 4102e82
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
19 changes: 19 additions & 0 deletions docs/adr/0031-markdown-for-terminal-output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 31. markdown for terminal output

Date: 2021-03-17

## Status

2021-03-17 proposed

## Context

Context here...

## Decision

Decision here...

## Consequences

Consequences here...
1 change: 1 addition & 0 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@
* [28. kubernetes-analysis](0028-kubernetes-analysis.md)
* [29. integration-openapi-source-code](0029-integration-openapi-source-code.md)
* [30. extract-infrastructure-mod](0030-extract-infrastructure-mod.md)
* [31. markdown-for-terminal-output](0031-markdown-for-terminal-output.md)
3 changes: 2 additions & 1 deletion src/app/analysis/git_analysis/commit_analysis.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::domain::git::CocoCommit;
use crate::infrastructure::git::cmd_git::commit_message;
use crate::infrastructure::git::git_log_parser::GitMessageParser;
use core_model::coco_config::CocoCommitConfig;
use core_model::url_format;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -37,7 +38,7 @@ impl ShortCommit {
}
}

pub fn analysis(url: &str) -> Vec<ShortCommit> {
pub fn analysis(url: &str, commit_config: Option<Vec<CocoCommitConfig>>) -> Vec<ShortCommit> {
let local_path = url_format::uri_to_path(url);

let messages = commit_message(Some(format!("{}", local_path.display())));
Expand Down
9 changes: 6 additions & 3 deletions src/app/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ use core_model::Settings;
use core_model::{CocoConfig, RepoConfig};

use crate::domain::CocoOpt;
use core_model::coco_config::CocoCommitConfig;
use rayon::prelude::*;
use std::time::Instant;

pub struct Analyst {
repos: Vec<RepoConfig>,
commit_config: Option<Vec<CocoCommitConfig>>,
}

impl From<&CocoConfig> for Analyst {
fn from(config: &CocoConfig) -> Self {
Self {
repos: config.repos.clone(),
commit_config: config.commit_config.clone(),
}
}
}
Expand All @@ -35,7 +38,7 @@ impl Analyst {
analysis_branches(url_str);
}
if cli_option.commits {
analysis_commits(url_str);
analysis_commits(url_str, self.commit_config.clone());
}
if cli_option.tags {
analysis_tags(url_str);
Expand Down Expand Up @@ -93,8 +96,8 @@ fn analysis_file_history(url_str: &str, git_years: f64) {
fs::write(output_file, result).expect("cannot write file");
}

fn analysis_commits(url_str: &str) {
let branches = commit_analysis::analysis(url_str);
fn analysis_commits(url_str: &str, commit_config: Option<Vec<CocoCommitConfig>>) {
let branches = commit_analysis::analysis(url_str, commit_config);
let file_name = url_format::json_filename_suffix(url_str, Some("-commits"));

let result = serde_json::to_string_pretty(&branches).unwrap();
Expand Down

0 comments on commit 4102e82

Please sign in to comment.