refuse a dependency add of an issue on itself
This commit is contained in:
parent
8895bfc63f
commit
a70b25847e
2 changed files with 19 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue