forked from kemitix/git-next
fix(actor/repo): always reschedule to validate repos
If validate repos saw anything unexpected it would stop and not schedule a re-validation.
This commit is contained in:
parent
af221f8a2f
commit
e272ca296b
1 changed files with 23 additions and 13 deletions
|
@ -29,35 +29,34 @@ pub async fn validate_positions(
|
||||||
Ok(commit_histories) => commit_histories,
|
Ok(commit_histories) => commit_histories,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(?err, "Failed to get commit histories");
|
error!(?err, "Failed to get commit histories");
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let Some(main) = commit_histories.main.first().cloned() else {
|
let Some(main) = commit_histories.main.first().cloned() else {
|
||||||
warn!("No commits on main branch '{}'", config.branches().main());
|
warn!("No commits on main branch '{}'", config.branches().main());
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
// verify that next is an ancestor of dev, and force update to it main if it isn't
|
// verify that next is an ancestor of dev, and force update to it main if it isn't
|
||||||
let Some(next) = commit_histories.next.first().cloned() else {
|
let Some(next) = commit_histories.next.first().cloned() else {
|
||||||
warn!("No commits on next branch '{}", config.branches().next());
|
warn!("No commits on next branch '{}", config.branches().next());
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let next_is_ancestor_of_dev = commit_histories.dev.iter().any(|dev| dev == &next);
|
let next_is_ancestor_of_dev = commit_histories.dev.iter().any(|dev| dev == &next);
|
||||||
if !next_is_ancestor_of_dev {
|
if !next_is_ancestor_of_dev {
|
||||||
info!("Next is not an ancestor of dev - resetting next to main");
|
info!("Next is not an ancestor of dev - resetting next to main");
|
||||||
|
let reset = git.reset(
|
||||||
if git
|
|
||||||
.reset(
|
|
||||||
&config.branches().next(),
|
&config.branches().next(),
|
||||||
main.into(),
|
main.into(),
|
||||||
ResetForce::Force(next.into()),
|
ResetForce::Force(next.into()),
|
||||||
&repo_details,
|
&repo_details,
|
||||||
)
|
);
|
||||||
.is_ok()
|
if let Err(err) = reset {
|
||||||
{
|
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(super::ValidateRepo)
|
|
||||||
}
|
}
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,10 +71,12 @@ pub async fn validate_positions(
|
||||||
config.branches().main(),
|
config.branches().main(),
|
||||||
config.branches().next()
|
config.branches().next()
|
||||||
);
|
);
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let Some(next) = next_commits.first().cloned() else {
|
let Some(next) = next_commits.first().cloned() else {
|
||||||
warn!("No commits on next branch '{}'", config.branches().next());
|
warn!("No commits on next branch '{}'", config.branches().next());
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let dev_has_next = commit_histories
|
let dev_has_next = commit_histories
|
||||||
|
@ -88,6 +89,7 @@ pub async fn validate_positions(
|
||||||
config.branches().dev(),
|
config.branches().dev(),
|
||||||
config.branches().next()
|
config.branches().next()
|
||||||
);
|
);
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return; // dev is not based on next
|
return; // dev is not based on next
|
||||||
}
|
}
|
||||||
let dev_has_main = commit_histories.dev.iter().any(|commit| commit == &main);
|
let dev_has_main = commit_histories.dev.iter().any(|commit| commit == &main);
|
||||||
|
@ -97,10 +99,12 @@ pub async fn validate_positions(
|
||||||
config.branches().dev(),
|
config.branches().dev(),
|
||||||
config.branches().main()
|
config.branches().main()
|
||||||
);
|
);
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let Some(dev) = commit_histories.dev.first().cloned() else {
|
let Some(dev) = commit_histories.dev.first().cloned() else {
|
||||||
warn!("No commits on dev branch '{}'", config.branches().dev());
|
warn!("No commits on dev branch '{}'", config.branches().dev());
|
||||||
|
revalidate_positions(addr).await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
addr.do_send(StartMonitoring {
|
addr.do_send(StartMonitoring {
|
||||||
|
@ -111,6 +115,12 @@ pub async fn validate_positions(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn revalidate_positions(addr: Addr<RepoActor>) {
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
// advance next to the next commit towards the head of the dev branch
|
// advance next to the next commit towards the head of the dev branch
|
||||||
#[tracing::instrument(fields(next), skip_all)]
|
#[tracing::instrument(fields(next), skip_all)]
|
||||||
pub async fn advance_next(
|
pub async fn advance_next(
|
||||||
|
|
Loading…
Reference in a new issue