Extract gitmessage_template_file_path to lib
This piece of code will be used in a variety of places, so let's put it somewhere where we can easily share it.
This commit is contained in:
parent
de5af01d1f
commit
41908686ed
|
|
@ -1,7 +1,7 @@
|
|||
use git2::Repository;
|
||||
use std::process;
|
||||
use std::fs::File;
|
||||
use git_mob::get_main_author;
|
||||
use git_mob::{get_main_author, gitmessage_template_file_path};
|
||||
|
||||
fn main() {
|
||||
let main_author = get_main_author();
|
||||
|
|
@ -19,6 +19,6 @@ fn main() {
|
|||
}
|
||||
|
||||
fn truncate_gitmessage_template(repo: Repository) {
|
||||
let template_path = repo.path().join(".gitmessage");
|
||||
let _template = File::create(template_path);
|
||||
let path = gitmessage_template_file_path(repo);
|
||||
let _template = File::create(path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use git2::Config;
|
||||
use git2::{Config, Repository};
|
||||
use std::fmt;
|
||||
use std::collections::BTreeMap;
|
||||
use dirs::home_dir;
|
||||
|
|
@ -54,3 +54,7 @@ fn parse_coauthors_file() -> Result<BTreeMap<String, Author>, Box<dyn Error>> {
|
|||
None => Ok(BTreeMap::new())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gitmessage_template_file_path(repo: Repository) -> std::path::PathBuf {
|
||||
repo.path().join(".gitmessage")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue