feat(server): extract git::reset from gitforge::forgejo
This commit is contained in:
parent
e5a8051a31
commit
e8062788a0
6 changed files with 7 additions and 36 deletions
3
src/server/git/mod.rs
Normal file
3
src/server/git/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
pub mod reset;
|
||||||
|
|
||||||
|
pub use reset::reset;
|
|
@ -36,7 +36,6 @@ pub fn reset(
|
||||||
git_dir: Some(gitdir.to_path_buf()),
|
git_dir: Some(gitdir.to_path_buf()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
// info!(?ctx, command = command.expose_secret(), "prepare");
|
|
||||||
match gix::command::prepare(command.expose_secret())
|
match gix::command::prepare(command.expose_secret())
|
||||||
.with_context(ctx)
|
.with_context(ctx)
|
||||||
.with_shell_allow_argument_splitting()
|
.with_shell_allow_argument_splitting()
|
|
@ -37,36 +37,4 @@ pub fn fetch(repo_details: &RepoDetails) -> Result<(), Error> {
|
||||||
info!("fetched");
|
info!("fetched");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
// INFO: never log the command as it contains the API token within the 'origin'
|
|
||||||
// let command: secrecy::Secret<String> = format!(
|
|
||||||
// "/usr/bin/git push {} {to_commit}:{branch_name} {force}",
|
|
||||||
// origin.expose_secret()
|
|
||||||
// )
|
|
||||||
// .into();
|
|
||||||
// info!("Resetting {branch_name} to {to_commit}");
|
|
||||||
// let ctx = gix::diff::command::Context {
|
|
||||||
// git_dir: Some(repo_details.gitdir.deref().clone()),
|
|
||||||
// ..Default::default()
|
|
||||||
// };
|
|
||||||
// // info!(?ctx, command = command.expose_secret(), "prepare");
|
|
||||||
// match gix::command::prepare(command.expose_secret())
|
|
||||||
// .with_context(ctx)
|
|
||||||
// .with_shell_allow_argument_splitting()
|
|
||||||
// // .stdout(std::process::Stdio::null())
|
|
||||||
// // .stderr(std::process::Stdio::null())
|
|
||||||
// .spawn()
|
|
||||||
// {
|
|
||||||
// Ok(mut child) => match child.wait() {
|
|
||||||
// Ok(_) => Ok(()),
|
|
||||||
// Err(err) => {
|
|
||||||
// warn!(?err, "Failed (wait)");
|
|
||||||
// Err(())
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// Err(err) => {
|
|
||||||
// warn!(?err, "Failed (spawn)");
|
|
||||||
// Err(())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
pub mod fetch;
|
pub mod fetch;
|
||||||
mod get_all;
|
mod get_all;
|
||||||
mod reset;
|
|
||||||
mod validate_positions;
|
mod validate_positions;
|
||||||
|
|
||||||
pub use fetch::fetch;
|
pub use fetch::fetch;
|
||||||
pub use get_all::get_all;
|
pub use get_all::get_all;
|
||||||
pub use reset::reset;
|
|
||||||
pub use validate_positions::validate_positions;
|
pub use validate_positions::validate_positions;
|
||||||
pub use validate_positions::ValidatedPositions;
|
pub use validate_positions::ValidatedPositions;
|
||||||
|
|
|
@ -12,6 +12,7 @@ use tracing::{error, info, warn};
|
||||||
use crate::server::{
|
use crate::server::{
|
||||||
actors::repo::{RepoActor, StartMonitoring, ValidateRepo},
|
actors::repo::{RepoActor, StartMonitoring, ValidateRepo},
|
||||||
config::{BranchName, GitDir, RepoConfig, RepoDetails},
|
config::{BranchName, GitDir, RepoConfig, RepoDetails},
|
||||||
|
git,
|
||||||
gitforge::{self, forgejo::branch::ValidatedPositions, RepoCloneError},
|
gitforge::{self, forgejo::branch::ValidatedPositions, RepoCloneError},
|
||||||
types::{GitRef, MessageToken},
|
types::{GitRef, MessageToken},
|
||||||
};
|
};
|
||||||
|
@ -80,7 +81,7 @@ impl super::ForgeLike for ForgeJoEnv {
|
||||||
force: gitforge::Force,
|
force: gitforge::Force,
|
||||||
) -> gitforge::BranchResetResult {
|
) -> gitforge::BranchResetResult {
|
||||||
branch::fetch(&self.repo_details)?;
|
branch::fetch(&self.repo_details)?;
|
||||||
branch::reset(&self.repo_details, branch_name, to_commit, force)
|
git::reset(&self.repo_details, branch_name, to_commit, force)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn commit_status(&self, commit: &gitforge::Commit) -> gitforge::CommitStatus {
|
async fn commit_status(&self, commit: &gitforge::Commit) -> gitforge::CommitStatus {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
mod actors;
|
mod actors;
|
||||||
mod config;
|
mod config;
|
||||||
|
pub mod git;
|
||||||
pub mod gitforge;
|
pub mod gitforge;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue