without autoescape

This commit is contained in:
2022-08-14 20:19:29 +02:00
parent 49089b3074
commit 319360968b
17 changed files with 1083 additions and 332 deletions

View File

@@ -0,0 +1,33 @@
use std::env::current_dir;
use git2::Repository;
#[derive(Debug)]
pub struct GitCommit {
pub commit_sha: String,
}
impl GitCommit {
pub fn new() -> anyhow::Result<GitCommit> {
let repo = Repository::open(current_dir().expect("having current_dir available")).map_err(
|e| {
log::debug!("{}", e);
anyhow::anyhow!("could not open repository")
},
)?;
let head_ref = repo
.head()
.map_err(|e| {
log::warn!("{}", e);
anyhow::anyhow!("could not get HEAD")
})?
.target()
.ok_or(anyhow::anyhow!(
"could not extract head -> target to commit_sha"
))?;
Ok(Self {
commit_sha: head_ref.to_string(),
})
}
}

View File

@@ -0,0 +1 @@
pub mod git;