refactor: reuse branch::reset to advance main branch to next

This commit is contained in:
Paul Campbell 2024-04-11 17:45:11 +01:00
parent 115b353389
commit ab58981f87

View file

@ -166,7 +166,6 @@ fn find_next_commit_on_dev(
} }
// advance main branch to the commit 'next' // advance main branch to the commit 'next'
#[allow(dead_code)]
pub async fn advance_main( pub async fn advance_main(
next: forge::Commit, next: forge::Commit,
repo_details: config::RepoDetails, repo_details: config::RepoDetails,
@ -174,31 +173,19 @@ pub async fn advance_main(
addr: Addr<RepoActor>, addr: Addr<RepoActor>,
) { ) {
info!("Advance Main"); info!("Advance Main");
let user = repo_details.forge.user; let result = reset(
let token = repo_details.forge.token; &repo_config.branches().main(),
let hostname = repo_details.forge.hostname; next,
let path = repo_details.repo; ResetForce::Normal,
let main = repo_config.branches().main(); &repo_details,
let command = );
format!("/usr/bin/git push https://{user}:{token}@{hostname}/{path}.git {next}:{main}"); match result {
info!("Running command: {}", command); Ok(_) => {
match gix::command::prepare(command) info!("Advance Next Success");
.with_shell_allow_argument_splitting() addr.do_send(StartRepo);
.spawn()
{
Ok(mut child) => {
match child.wait() {
Ok(exit_status) => {
info!(%exit_status, "Advance Next Success");
addr.do_send(StartRepo);
}
Err(err) => {
warn!(?err, "Advance Next Failed (wait)")
}
};
} }
Err(err) => { Err(err) => {
warn!(?err, "Advance Next Failed (spawn)") warn!(?err, "Advance Next Failed")
} }
}; };
} }