fix(hive-forge): populate owner/repo in dependency add/remove body
This commit is contained in:
parent
b8e19a31b2
commit
bad5285f2e
1 changed files with 16 additions and 8 deletions
|
|
@ -53,7 +53,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||||
for dep in &deps {
|
for dep in &deps {
|
||||||
client
|
client
|
||||||
.api()
|
.api()
|
||||||
.issue_create_issue_dependencies(owner, name, idx, dep_meta(*dep)?)
|
.issue_create_issue_dependencies(owner, name, idx, dep_meta(owner, name, *dep)?)
|
||||||
.send()?;
|
.send()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +64,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||||
for dep in &deps {
|
for dep in &deps {
|
||||||
client
|
client
|
||||||
.api()
|
.api()
|
||||||
.issue_remove_issue_dependencies(owner, name, idx, dep_meta(*dep)?)
|
.issue_remove_issue_dependencies(owner, name, idx, dep_meta(owner, name, *dep)?)
|
||||||
.send()?;
|
.send()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,13 +73,21 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||||
print_json(&serde_json::json!(deps))
|
print_json(&serde_json::json!(deps))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build the `IssueMeta` body the create/remove endpoints want — just the
|
/// Build the `IssueMeta` body the create/remove endpoints want.
|
||||||
/// dependency's index; `owner`/`repo` stay `None` since this CLI only
|
///
|
||||||
/// supports same-repo dependencies (matching the forge web UI).
|
/// `owner`/`repo` are filled in with the *same* repo the request URL
|
||||||
fn dep_meta(dep: u64) -> Result<IssueMeta> {
|
/// 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 <n> add <dep>`
|
||||||
|
/// 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<IssueMeta> {
|
||||||
Ok(IssueMeta {
|
Ok(IssueMeta {
|
||||||
index: Some(index(dep)?),
|
index: Some(index(dep)?),
|
||||||
owner: None,
|
owner: Some(owner.to_owned()),
|
||||||
repo: None,
|
repo: Some(repo.to_owned()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue