Compare commits

...

2 Commits

3 changed files with 25 additions and 8 deletions

View File

@ -1,6 +1,6 @@
# git-heatmap
simple but customizable heatmap for your local git repos written in Rust.
simple but customizable heatmap for your **local** git repos written in Rust.
![screenshot](screenshot.png)
@ -47,6 +47,9 @@ $ git-heatmap -r "/path/to/repo" -b "main" -r "other/repo" -b ""
# which branches should be checked per repo, in this case all branches will be checked.
$ git-heatmap --root-dir "/path"
# when using the --root-dir option you can also ignore folders of repos you don't want to count
$ git-heatmap --root-dir "/path" -i "project"
# by default merges are counted so using --no-merges ensures they won't be counted
$ git-heatmap --no-merges

View File

@ -23,6 +23,9 @@ pub struct CliArgs {
#[arg(short, long, num_args(0..), value_hint = ValueHint::DirPath)]
pub repos: Option<Vec<PathBuf>>,
#[arg(short('i'), long("igore"), num_args(0..))]
pub ignored_repos: Option<Vec<String>>,
#[arg(short, long, num_args(0..))]
pub branches: Option<Vec<String>>,

View File

@ -63,7 +63,7 @@ struct Author {
}
fn main() -> Result<()> {
clear_screen();
// clear_screen();
let args = CliArgs::parse();
@ -154,24 +154,33 @@ fn get_color_map() -> Vec<String> {
.to_vec()
}
fn find_git_repos(scan_path: &path::Path, repos: &mut Vec<PathBuf>, _args: &CliArgs) {
fn find_git_repos(
scan_path: &path::Path,
repos: &mut Vec<PathBuf>,
ignored_repos: &Vec<String>,
_args: &CliArgs,
) {
let Ok(dirs) = scan_path.read_dir()
else {
return;
};
let dirs: Vec<_> = dirs
.filter_map(|f| f.ok())
.filter(|f| f.file_type().is_ok_and(|t| t.is_dir()))
.filter_map(|d| d.ok())
.filter(|d| {
let dir_name = d.file_name().to_string_lossy().to_string();
!ignored_repos.contains(&dir_name)
})
.filter(|d| d.file_type().is_ok_and(|t| t.is_dir()))
.collect_vec();
let dirs = dirs.iter().map(|f| f.path());
let dirs = dirs.iter().map(|d| d.path());
for dir in dirs {
let filename = dir.file_name().unwrap_or_default().to_string_lossy();
match filename.as_ref() {
".git" => repos.push(dir),
_ => find_git_repos(&dir, repos, _args),
_ => find_git_repos(&dir, repos, ignored_repos, _args),
}
}
}
@ -183,10 +192,12 @@ fn get_commits(
) -> Result<(usize, Vec<Commit>)> {
let mut commits: HashSet<Commit> = HashSet::new();
let ignored_repos = args.ignored_repos.as_ref().unwrap_or(&vec![]).to_owned();
let (repos, branches) = match &args.root_dir {
Some(root) => {
let mut repos: Vec<PathBuf> = vec![];
find_git_repos(root, &mut repos, &args);
find_git_repos(root, &mut repos, &ignored_repos, &args);
let branches = vec!["".to_string(); repos.len()];
(repos, branches)
}