From e60fae7031f6d979b32b388f7590ed3f9537aece Mon Sep 17 00:00:00 2001 From: Martin Frost Date: Tue, 10 Nov 2020 13:32:40 +0100 Subject: [PATCH] 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 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a5e344..275d974 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -157,7 +157,7 @@ dependencies = [ [[package]] name = "git_mob" -version = "0.3.3" +version = "0.3.4" dependencies = [ "dirs", "git2", diff --git a/Cargo.toml b/Cargo.toml index 23eddb5..e4946f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git_mob" -version = "0.3.3" +version = "0.3.4" authors = ["Martin Frost "] edition = "2018" description = "A CLI tool for social coding." diff --git a/src/lib.rs b/src/lib.rs index ac6206c..11020e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,7 +24,11 @@ impl fmt::Display for 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 email = cfg.get_entry("user.email").unwrap();