From bad5285f2ef89ebdc743d11218ca85bea46fac78 Mon Sep 17 00:00:00 2001 From: damocles Date: Sun, 16 Aug 2026 14:39:11 +0200 Subject: [PATCH] fix(hive-forge): populate owner/repo in dependency add/remove body --- hive-forge/src/verbs/dependency.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/hive-forge/src/verbs/dependency.rs b/hive-forge/src/verbs/dependency.rs index 2e53f9af..318f29e2 100644 --- a/hive-forge/src/verbs/dependency.rs +++ b/hive-forge/src/verbs/dependency.rs @@ -53,7 +53,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> { for dep in &deps { client .api() - .issue_create_issue_dependencies(owner, name, idx, dep_meta(*dep)?) + .issue_create_issue_dependencies(owner, name, idx, dep_meta(owner, name, *dep)?) .send()?; } } @@ -64,7 +64,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> { for dep in &deps { client .api() - .issue_remove_issue_dependencies(owner, name, idx, dep_meta(*dep)?) + .issue_remove_issue_dependencies(owner, name, idx, dep_meta(owner, name, *dep)?) .send()?; } } @@ -73,13 +73,21 @@ pub fn run(client: &Client, args: Args) -> Result<()> { print_json(&serde_json::json!(deps)) } -/// Build the `IssueMeta` body the create/remove endpoints want — just the -/// dependency's index; `owner`/`repo` stay `None` since this CLI only -/// supports same-repo dependencies (matching the forge web UI). -fn dep_meta(dep: u64) -> Result { +/// Build the `IssueMeta` body the create/remove endpoints want. +/// +/// `owner`/`repo` are filled in with the *same* repo the request URL +/// already targets — not left `None`. Forgejo's dependency handler +/// resolves the dependency's repo from these body fields rather than +/// defaulting an absent value to the URL's own owner/repo, so omitting +/// them 404s looking up an empty-string repo (`owner/repo: not found` +/// — measured, not guessed: `hive-forge dependency add ` +/// failed this way for every same-repo pair before this fix). This CLI +/// still only supports same-repo dependencies (matching the forge web +/// UI) — the fields are populated, not opened up to cross-repo. +fn dep_meta(owner: &str, repo: &str, dep: u64) -> Result { Ok(IssueMeta { index: Some(index(dep)?), - owner: None, - repo: None, + owner: Some(owner.to_owned()), + repo: Some(repo.to_owned()), }) }