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