1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::fs;
use std::path::PathBuf;
use git2::Repository;
use crate::external::Error;
pub fn read_toml(path: PathBuf) -> Result<String, Error> {
let repository = Repository::discover(path)?;
let path = repository.path();
let bare = path.parent().unwrap_or(path).join(".git-mit.toml");
let dist = path.parent().unwrap_or(path).join(".git-mit.toml.dist");
if bare.exists() {
return Ok(fs::read_to_string(bare)?);
}
if dist.exists() {
return Ok(fs::read_to_string(dist)?);
}
Ok("".to_string())
}