hive-forge: hard-error unresolved --label names; render dependency timeline events

This commit is contained in:
damocles 2026-08-02 04:41:52 +02:00 committed by mara
commit 7bad72d354
4 changed files with 134 additions and 20 deletions

View file

@ -69,11 +69,13 @@ pub struct Args {
#[arg(long)]
topic: Option<String>,
/// Label name to attach, repeatable (e.g. `--label area/ops --label
/// type/bug`). Same spelling `labels add` accepts. In `--agit` mode
/// this is applied as a follow-up call once the PR number is known
/// (the `AGit` push itself has no label field), so it's silently
/// skipped if the PR URL couldn't be parsed back out of the push
/// output — same fallback as the deferred multi-line body.
/// type/bug`). Same spelling `labels add` accepts — an unresolved name
/// errors out rather than silently attaching fewer labels than asked
/// for. In `--agit` mode this is applied as a follow-up call once the
/// PR number is known (the `AGit` push itself has no label field), so
/// it's silently skipped (not a label-resolution error) if the PR URL
/// couldn't be parsed back out of the push output — same fallback as
/// the deferred multi-line body.
#[arg(long = "label")]
labels: Vec<String>,
}
@ -83,8 +85,8 @@ pub struct Args {
/// Propagates any I/O error from the body input (`--body-file`,
/// stdin) or the `--push` shellout to git, any transport error from
/// the Forgejo REST call (network unreachable, 4xx/5xx response,
/// token missing/invalid), and any I/O error from writing the PR
/// URL to stdout.
/// token missing/invalid), an unresolved `--label` name, and any I/O
/// error from writing the PR URL to stdout.
pub fn run(client: &Client, args: Args) -> Result<()> {
let body = body::resolve(args.body.as_deref(), args.body_file.as_deref())?.unwrap_or_default();
if args.agit {
@ -105,7 +107,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
None
} else {
let all = labels::repo_labels(client)?;
Some(labels::resolve_ids(&all, &args.labels))
Some(labels::resolve_ids(&all, &args.labels)?)
};
// Note: Forgejo's CreatePullRequestOption has no `draft` /
// `allow_maintainer_edit` fields (verified against the instance's
@ -249,7 +251,7 @@ fn apply_agit_labels(client: &Client, names: &[String], url: &str) -> Result<()>
};
let (owner, name) = client.owner_repo()?;
let all = labels::repo_labels(client)?;
let ids: Vec<serde_json::Value> = labels::resolve_ids(&all, names)
let ids: Vec<serde_json::Value> = labels::resolve_ids(&all, names)?
.into_iter()
.map(|id| json!(id))
.collect();