Rustfmt everything

This commit is contained in:
Martin Frost 2020-09-05 16:07:58 +02:00 committed by Martin Frost
parent a5ff50fd1b
commit 20997a0605
6 changed files with 42 additions and 41 deletions

View File

@ -1,4 +1,4 @@
use git_mob::{Author, get_available_coauthors, write_coauthors_file} ;
use git_mob::{get_available_coauthors, write_coauthors_file, Author};
use structopt::StructOpt;
#[derive(StructOpt, Debug)]

View File

@ -1,6 +1,6 @@
use git_mob::{Author, get_available_coauthors, write_coauthors_file} ;
use structopt::StructOpt;
use git_mob::{get_available_coauthors, write_coauthors_file, Author};
use std::process;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
struct Opt {

View File

@ -1,7 +1,10 @@
use git_mob::{Author, get_main_author, get_available_coauthors, with_gitmessage_template_path_or_exit, set_main_author};
use structopt::StructOpt;
use std::process;
use git_mob::{
get_available_coauthors, get_main_author, set_main_author,
with_gitmessage_template_path_or_exit, Author,
};
use std::fs;
use std::process;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
struct Opt {
@ -54,18 +57,16 @@ fn write_coauthors_to_gitmessage_file(coauthor_initials: &[String]) {
content.push_str(&format!("Co-authored-by: {}\n", &author.to_string()));
}
with_gitmessage_template_path_or_exit(|path| {
match fs::write(path, content) {
with_gitmessage_template_path_or_exit(|path| match fs::write(path, content) {
Ok(_) => {
println!("{}", get_main_author());
for author in &coauthors {
println!("{}", author);
}
},
}
Err(e) => {
eprintln!("Error writing to .gitmessage template: {}", e);
process::exit(1);
},
}
});
}

View File

@ -1,5 +1,5 @@
use std::fs::File;
use git_mob::{get_main_author, with_gitmessage_template_path_or_exit};
use std::fs::File;
fn main() {
let main_author = get_main_author();

View File

@ -1,15 +1,15 @@
use serde::{Deserialize, Serialize};
use std::fs;
use git2::{Config, Repository};
use std::fmt;
use std::collections::BTreeMap;
use dirs::home_dir;
use git2::{Config, Repository};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fmt;
use std::fs;
use std::io::BufReader;
use std::fs::File;
use std::error::Error;
use std::string::String;
use std::fs::File;
use std::io::BufReader;
use std::process;
use std::string::String;
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Author {
@ -61,7 +61,7 @@ fn parse_coauthors_file() -> Result<BTreeMap<String, Author>, Box<dyn Error>> {
match json_data.get("coauthors") {
Some(coauthors) => Ok(serde_json::from_value(coauthors.clone()).unwrap()),
None => Ok(BTreeMap::new())
None => Ok(BTreeMap::new()),
}
}
@ -69,7 +69,7 @@ fn with_git_repo_or_exit<F: FnOnce(Repository)>(f: F) {
match Repository::open_from_env() {
Ok(repo) => {
f(repo);
},
}
Err(_e) => {
eprintln!("Not in a git repository");
process::exit(1);
@ -89,7 +89,7 @@ pub fn write_coauthors_file(authors: BTreeMap<String, Author>) {
wrapper_tree.insert("coauthors", authors);
let json_data = serde_json::to_string_pretty(&wrapper_tree).unwrap();
match fs::write(coauthors_file_path(), json_data) {
Ok(_) => {},
Ok(_) => {}
Err(e) => {
eprintln!("Error writing git-coauthors file: {:?}", e);
process::exit(1);