Watch
0
0
Fork
You've already forked hyperhive
0

refuse a dependency add of an issue on itself

This commit is contained in:
atlas 2026-10-27 14:38:06 +01:00 • committed by mara
commit a70b25847e
2 changed files with 19 additions and 0 deletions

View file

@ -202,6 +202,11 @@ fn apply_and_verify(
/// `Internal Server Error`) and accepts longer cycles without complaint,
/// so the check walks `dependency list` client-side.
fn refuse_cycle(client: &Client, owner: &str, name: &str, number: u64, dep: u64) -> Result<()> {
if dep == number {
bail!(
"hive-forge dependency add: #{number} cannot depend on itself, which would create a cycle"
);
}
let path = find_dependency_path(dep, number, |n| {
let deps = dependency_summaries(client, owner, name, n)?;
Ok(deps

View file

@ -149,3 +149,17 @@ fn non_cyclic_add_reaches_the_forge() {
fn tag(n: u64) -> String {
format!("{}{n}", '#')
}
#[test]
fn self_dependency_is_refused_before_any_post() {
let (ok, stderr, posts) = add("self", "10", "10");
assert!(!ok);
assert!(
stderr.contains(&format!(
"{} cannot depend on itself, which would create a cycle",
tag(10)
)),
"{stderr}"
);
assert_eq!(posts, 0);
}