Skip to content

Commit

Permalink
feat(explorer): make export file history
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 4, 2021
1 parent 55a3f44 commit a9b3b9c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions locales/translate/zh-CN/suggest.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ package-description = 一个包就是被组织成一个物理内聚单位的组
knowledge-transform = 知识转换成本依赖于项目复杂度(代码量、上手难度)、组织成员的变更数。
learning-curve-desc = 项目的上手复杂度与开发人员的提交量成正比,即复杂的项目上手成本越高,短期的提交量越少。Coco 是根据最近 30 周的提交次数/代码修改行数,绘制出来的曲线。(适用于以团队为单位的软件开发)。
members-lifecycle-desc = 软件团队的规模呈线性增长时,沟通成本介于线性增长和指数级增长之间。而离职人员数越多时,则会因为新成员不了解系统的设计,就可能增加出错的可能性。
metrics-purpose = 1. 帮助跟踪和理解发生了什么。 2. 帮助人们沟通发生的事情。 3. 帮助人们关注那些他们真正需要改善的事情。
10 changes: 10 additions & 0 deletions src/app/analysis/git_analysis/file_analysis.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use crate::infrastructure::git::git_file_history;
use core_model::url_format;
use git_scanner::flare::FlareTreeNode;

pub fn analysis(url: &str) -> FlareTreeNode {
let local_path = url_format::uri_to_path(url);
let tree_node = git_file_history::by_path(local_path);

return tree_node;
}
1 change: 1 addition & 0 deletions src/app/analysis/git_analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ pub use format_branch::FormatBranch;

pub mod branch_analysis;
pub mod commit_analysis;
pub mod file_analysis;
pub mod format_branch;
pub mod tag_analysis;
11 changes: 11 additions & 0 deletions src/app/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl Analyst {
analysis_branches(url_str);
analysis_commits(url_str);
analysis_tags(url_str);
analysis_file_history(url_str);

analysis_framework(url_str);
analysis_cloc(url_str);
Expand Down Expand Up @@ -77,6 +78,16 @@ fn analysis_tags(url_str: &str) {
fs::write(output_file, result).expect("cannot write file");
}

fn analysis_file_history(url_str: &str) {
let tree = file_analysis::analysis(url_str);
let file_name = url_format::json_filename_suffix(url_str, Some("-file-history"));

let result = serde_json::to_string_pretty(&tree).unwrap();
let output_file = Settings::git().join(file_name);

fs::write(output_file, result).expect("cannot write file");
}

fn analysis_commits(url_str: &str) {
let branches = commit_analysis::analysis(url_str);
let file_name = url_format::json_filename_suffix(url_str, Some("-commits"));
Expand Down
4 changes: 0 additions & 4 deletions src/infrastructure/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ mod test {
use crate::infrastructure::git::git_log_parser::GitMessageParser;
use crate::infrastructure::git::{git_file_history, GitRepository};
use core_model::url_format;
use std::fs;

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

Expand Down Expand Up @@ -99,9 +98,6 @@ mod test {
let root = url_format::uri_to_path("https://github.com/coco-rs/coco.fixtures");
let tree = git_file_history::by_path(root);

let json = serde_json::to_string(&tree).unwrap();
fs::write("demo.json", json).unwrap();

let name = tree.get_children()[0].name();
assert_eq!("LICENSE", name.to_str().unwrap());
}
Expand Down

0 comments on commit a9b3b9c

Please sign in to comment.