put in right namespace

This commit is contained in:
Kasper Juul Hermansen 2022-11-24 13:02:13 +01:00
parent 6e13263009
commit 0f8db6be08
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -1,6 +1,6 @@
use std::{path::PathBuf, sync::Arc};
use git2::{Cred, RemoteCallbacks, Repository};
use git2::{Cred, RemoteCallbacks, Repository, Signature};
use tokio::sync::Mutex;
use crate::{schema::models::GitPushBranch, storage::DynStorageEngine};
@ -85,6 +85,31 @@ impl GitProvider for GitHubGitProvider {
branch: &GitPushBranch,
) -> eyre::Result<()> {
let repo = repo.lock().await;
let signature = repo.signature()?;
let mut index = repo.index()?;
index.add_path(PathBuf::from(".").as_path())?;
index.write()?;
let tree = index.write_tree()?;
let tree = repo.find_tree(tree)?;
let parents = repo.head().map(|h| {
h.target()
.ok_or(eyre::anyhow!("could not fetch target"))
.map(|t| repo.find_commit(t))
})???;
repo.commit(
None,
&signature,
&signature,
branch.name.to_lowercase().replace(" ", "-").as_str(),
&tree,
&[&parents],
)?;
Ok(())
}
}