fix(repo/branch): revalidate positions in more conditions
All checks were successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful

- when next has no commits
- when couldn't reset next to a commit (e.g. commit was WIP)
This commit is contained in:
Paul Campbell 2024-04-13 16:22:49 +01:00
parent 0622e6092b
commit 4c4ac4df25

View file

@ -163,28 +163,24 @@ pub async fn advance_next(
let next_commit = find_next_commit_on_dev(next, dev_commit_history); let next_commit = find_next_commit_on_dev(next, dev_commit_history);
let Some(commit) = next_commit else { let Some(commit) = next_commit else {
warn!("No commits to advance next to"); warn!("No commits to advance next to");
revalidate_positions(addr).await;
return; return;
}; };
if let Some(problem) = validate_commit_message(commit.message()) { if let Some(problem) = validate_commit_message(commit.message()) {
warn!("Can't advance next to commit '{}': {}", commit, problem); warn!("Can't advance next to commit '{}': {}", commit, problem);
revalidate_positions(addr).await;
return; return;
} }
info!("Advancing next to commit '{}'", commit); info!("Advancing next to commit '{}'", commit);
match git.reset( if let Err(err) = git.reset(
&repo_config.branches().next(), &repo_config.branches().next(),
commit.into(), commit.into(),
ResetForce::None, ResetForce::None,
&repo_details, &repo_details,
) { ) {
Ok(_) => { warn!(?err, "Failed")
// TODO : (#18) sleep and restart while we don't have webhooks
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
addr.do_send(ValidateRepo);
}
Err(err) => {
warn!(?err, "Failed")
}
}; };
revalidate_positions(addr).await;
} }
#[tracing::instrument] #[tracing::instrument]