Stop printing on stderr when adding first coauthor
Before this change, when running `git add-coauthor` without an existing `~/.git-coauthors` file, the program would print an error message on stderr that the file did not exist. It would then create the file with the newly added co-author in it. That message seemed unnecessary and so it has now been removed. Co-authored-by: Maria Hansson <mariahansson92@hotmail.com>
This commit is contained in:
parent
bb38091506
commit
9be6f97a5e
|
|
@ -1,4 +1,4 @@
|
|||
use git_mob::{get_available_coauthors, write_coauthors_file, Author};
|
||||
use git_mob::{parse_coauthors_file, write_coauthors_file, Author};
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(StructOpt, Debug)]
|
||||
|
|
@ -13,11 +13,12 @@ struct Opt {
|
|||
|
||||
fn main() {
|
||||
let opt = Opt::from_args();
|
||||
let mut authors = get_available_coauthors();
|
||||
let mut authors = parse_coauthors_file().unwrap_or_default();
|
||||
let new_author = Author {
|
||||
name: opt.name,
|
||||
email: opt.email,
|
||||
};
|
||||
|
||||
authors.insert(opt.initials, new_author);
|
||||
|
||||
write_coauthors_file(authors);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ pub fn get_available_coauthors() -> BTreeMap<String, Author> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_coauthors_file() -> Result<BTreeMap<String, Author>, Box<dyn Error>> {
|
||||
pub fn parse_coauthors_file() -> Result<BTreeMap<String, Author>, Box<dyn Error>> {
|
||||
let coauthors_path = coauthors_file_path();
|
||||
let coauthors_file = File::open(coauthors_path)?;
|
||||
let reader = BufReader::new(coauthors_file);
|
||||
|
|
|
|||
Loading…
Reference in New Issue