Move get_main_author -> lib.rs
This commit is contained in:
parent
8032a08656
commit
0061c5b112
|
|
@ -1,9 +1,11 @@
|
||||||
use std::fs::File;
|
use git2::Repository;
|
||||||
use std::process;
|
use std::process;
|
||||||
use git2::{Config, Repository};
|
use std::fs::File;
|
||||||
|
use git_mob::get_main_author;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("{}", get_main_author());
|
let main_author = get_main_author();
|
||||||
|
println!("{}", main_author);
|
||||||
|
|
||||||
match Repository::open_from_env() {
|
match Repository::open_from_env() {
|
||||||
Ok(repo) => {
|
Ok(repo) => {
|
||||||
|
|
@ -16,16 +18,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_main_author() -> String {
|
|
||||||
let cfg = Config::open_default().unwrap();
|
|
||||||
let name = cfg.get_entry("user.name").unwrap();
|
|
||||||
let name = name.value().unwrap();
|
|
||||||
let email = cfg.get_entry("user.email").unwrap();
|
|
||||||
let email = email.value().unwrap();
|
|
||||||
|
|
||||||
format!("{} <{}>", name, email)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn truncate_gitmessage_template(repo: Repository) {
|
fn truncate_gitmessage_template(repo: Repository) {
|
||||||
let template_path = repo.path().join(".gitmessage");
|
let template_path = repo.path().join(".gitmessage");
|
||||||
let _template = File::create(template_path);
|
let _template = File::create(template_path);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
use std::fs::File;
|
||||||
|
use git2::{Config, Repository};
|
||||||
|
|
||||||
|
pub fn get_main_author() -> Author {
|
||||||
|
let cfg = Config::open_default().unwrap();
|
||||||
|
let name = cfg.get_entry("user.name").unwrap();
|
||||||
|
let email = cfg.get_entry("user.email").unwrap();
|
||||||
|
|
||||||
|
Author {
|
||||||
|
name: name.value().unwrap().to_string(),
|
||||||
|
email: email.value().unwrap().to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue