v0.3.4 - Print correct main author

This change makes `get_main_author` try to fetch `user.name` and
`user.email` from the current repo before falling back to a global
default.

Co-authored-by: Maria Hansson <mariahansson92@hotmail.com>
This commit is contained in:
Martin Frost 2020-11-10 13:32:40 +01:00
parent 4575605991
commit e60fae7031
3 changed files with 7 additions and 3 deletions

2
Cargo.lock generated
View File

@ -157,7 +157,7 @@ dependencies = [
[[package]] [[package]]
name = "git_mob" name = "git_mob"
version = "0.3.3" version = "0.3.4"
dependencies = [ dependencies = [
"dirs", "dirs",
"git2", "git2",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "git_mob" name = "git_mob"
version = "0.3.3" version = "0.3.4"
authors = ["Martin Frost <martin@frost.ws>"] authors = ["Martin Frost <martin@frost.ws>"]
edition = "2018" edition = "2018"
description = "A CLI tool for social coding." description = "A CLI tool for social coding."

View File

@ -24,7 +24,11 @@ impl fmt::Display for Author {
} }
pub fn get_main_author() -> Author { pub fn get_main_author() -> Author {
let cfg = Config::open_default().unwrap(); let cfg = match Repository::open_from_env() {
Ok(repo) => repo.config().unwrap(),
Err(_e) => Config::open_default().unwrap()
};
let name = cfg.get_entry("user.name").unwrap(); let name = cfg.get_entry("user.name").unwrap();
let email = cfg.get_entry("user.email").unwrap(); let email = cfg.get_entry("user.email").unwrap();