From 0f8db6be08338b6000d5ed739881ae2b4cae62b0 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Thu, 24 Nov 2022 13:02:13 +0100 Subject: [PATCH] put in right namespace --- crates/octopush_core/src/git/github.rs | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/octopush_core/src/git/github.rs b/crates/octopush_core/src/git/github.rs index 310314e..12ecf1b 100644 --- a/crates/octopush_core/src/git/github.rs +++ b/crates/octopush_core/src/git/github.rs @@ -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(()) } }