fix(repo/branch): revalidate positions in more conditions

- 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(_) => {
// 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") warn!(?err, "Failed")
}
}; };
revalidate_positions(addr).await;
} }
#[tracing::instrument] #[tracing::instrument]