forked from kemitix/git-next
refactor: reuse branch::reset to advance next towards dev
This commit is contained in:
parent
6bad8a27f7
commit
e0b15712c2
1 changed files with 12 additions and 26 deletions
|
@ -108,6 +108,7 @@ pub async fn validate_positions(
|
|||
}
|
||||
|
||||
// advance next to the next commit towards the head of the dev branch
|
||||
#[tracing::instrument(fields(next), skip_all)]
|
||||
pub async fn advance_next(
|
||||
next: forge::Commit,
|
||||
dev_commit_history: Vec<forge::Commit>,
|
||||
|
@ -115,38 +116,23 @@ pub async fn advance_next(
|
|||
repo_config: config::RepoConfig,
|
||||
addr: Addr<RepoActor>,
|
||||
) {
|
||||
info!("Advance Next");
|
||||
let user = repo_details.forge.user;
|
||||
let token = repo_details.forge.token;
|
||||
let hostname = repo_details.forge.hostname;
|
||||
let path = repo_details.repo;
|
||||
let next_commit = find_next_commit_on_dev(next, dev_commit_history);
|
||||
let Some(commit) = next_commit else {
|
||||
warn!("No commits to advance next to");
|
||||
return;
|
||||
};
|
||||
let next = repo_config.branches().next();
|
||||
let command =
|
||||
format!("/usr/bin/git push https://{user}:{token}@{hostname}/{path}.git {commit}:{next}");
|
||||
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");
|
||||
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
|
||||
addr.do_send(StartRepo);
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(?err, "Advance Next Failed (wait)")
|
||||
}
|
||||
};
|
||||
match reset(
|
||||
&repo_config.branches().next(),
|
||||
commit,
|
||||
ResetForce::Normal,
|
||||
&repo_details,
|
||||
) {
|
||||
Ok(_) => {
|
||||
info!("Success");
|
||||
addr.do_send(StartRepo);
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(?err, "Advance Next Failed (spawn)")
|
||||
warn!(?err, "Failed")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -166,7 +152,7 @@ fn find_next_commit_on_dev(
|
|||
}
|
||||
|
||||
// advance main branch to the commit 'next'
|
||||
#[tracing::instrument(fields(next))]
|
||||
#[tracing::instrument(fields(next), skip_all)]
|
||||
pub async fn advance_main(
|
||||
next: forge::Commit,
|
||||
repo_details: config::RepoDetails,
|
||||
|
|
Loading…
Reference in a new issue