feat(#1940): expose pr_number on approvalview for merge_config_pr
This commit is contained in:
parent
e593547063
commit
658812c263
1 changed files with 16 additions and 0 deletions
|
|
@ -441,6 +441,13 @@ struct ApprovalView {
|
||||||
/// Manager-supplied description shown on the approval card.
|
/// Manager-supplied description shown on the approval card.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
|
/// Forge PR number, for `MergeConfigPr` only. Lets the frontend
|
||||||
|
/// build a "review PR on forge" link
|
||||||
|
/// (`{forgeBase}/agent-configs/{agent}/pulls/{pr_number}`) the same
|
||||||
|
/// way it builds the `apply_commit` "commit on forge" link from the
|
||||||
|
/// sha. `None` for every other kind.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pr_number: Option<u64>,
|
||||||
/// Unix seconds the approval was queued. Rendered as a relative
|
/// Unix seconds the approval was queued. Rendered as a relative
|
||||||
/// time on the card so the operator can spot a stale request.
|
/// time on the card so the operator can spot a stale request.
|
||||||
requested_at: i64,
|
requested_at: i64,
|
||||||
|
|
@ -901,6 +908,7 @@ async fn build_approval_views(approvals: Vec<Approval>) -> Vec<ApprovalView> {
|
||||||
sha_short: Some(sha),
|
sha_short: Some(sha),
|
||||||
diff: Some(diff),
|
diff: Some(diff),
|
||||||
description: a.description,
|
description: a.description,
|
||||||
|
pr_number: None,
|
||||||
requested_at: a.requested_at,
|
requested_at: a.requested_at,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -911,6 +919,7 @@ async fn build_approval_views(approvals: Vec<Approval>) -> Vec<ApprovalView> {
|
||||||
sha_short: None,
|
sha_short: None,
|
||||||
diff: None,
|
diff: None,
|
||||||
description: a.description,
|
description: a.description,
|
||||||
|
pr_number: None,
|
||||||
requested_at: a.requested_at,
|
requested_at: a.requested_at,
|
||||||
},
|
},
|
||||||
hive_sh4re::ApprovalKind::InitConfig => ApprovalView {
|
hive_sh4re::ApprovalKind::InitConfig => ApprovalView {
|
||||||
|
|
@ -920,6 +929,7 @@ async fn build_approval_views(approvals: Vec<Approval>) -> Vec<ApprovalView> {
|
||||||
sha_short: None,
|
sha_short: None,
|
||||||
diff: None,
|
diff: None,
|
||||||
description: a.description,
|
description: a.description,
|
||||||
|
pr_number: None,
|
||||||
requested_at: a.requested_at,
|
requested_at: a.requested_at,
|
||||||
},
|
},
|
||||||
hive_sh4re::ApprovalKind::UpdateMetaInputs => ApprovalView {
|
hive_sh4re::ApprovalKind::UpdateMetaInputs => ApprovalView {
|
||||||
|
|
@ -929,6 +939,7 @@ async fn build_approval_views(approvals: Vec<Approval>) -> Vec<ApprovalView> {
|
||||||
sha_short: None,
|
sha_short: None,
|
||||||
diff: None,
|
diff: None,
|
||||||
description: a.description,
|
description: a.description,
|
||||||
|
pr_number: None,
|
||||||
requested_at: a.requested_at,
|
requested_at: a.requested_at,
|
||||||
},
|
},
|
||||||
hive_sh4re::ApprovalKind::SchedulePrompt => ApprovalView {
|
hive_sh4re::ApprovalKind::SchedulePrompt => ApprovalView {
|
||||||
|
|
@ -938,6 +949,7 @@ async fn build_approval_views(approvals: Vec<Approval>) -> Vec<ApprovalView> {
|
||||||
sha_short: None,
|
sha_short: None,
|
||||||
diff: None,
|
diff: None,
|
||||||
description: a.description,
|
description: a.description,
|
||||||
|
pr_number: None,
|
||||||
requested_at: a.requested_at,
|
requested_at: a.requested_at,
|
||||||
},
|
},
|
||||||
hive_sh4re::ApprovalKind::MergeConfigPr => {
|
hive_sh4re::ApprovalKind::MergeConfigPr => {
|
||||||
|
|
@ -948,6 +960,9 @@ async fn build_approval_views(approvals: Vec<Approval>) -> Vec<ApprovalView> {
|
||||||
.fetched_sha
|
.fetched_sha
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|s| s[..s.len().min(12)].to_owned());
|
.map(|s| s[..s.len().min(12)].to_owned());
|
||||||
|
// Surface the PR number so the frontend can link to the
|
||||||
|
// PR on the forge. commit_ref holds the number as text.
|
||||||
|
let pr_number = a.commit_ref.parse::<u64>().ok();
|
||||||
ApprovalView {
|
ApprovalView {
|
||||||
id: a.id,
|
id: a.id,
|
||||||
agent: a.agent,
|
agent: a.agent,
|
||||||
|
|
@ -955,6 +970,7 @@ async fn build_approval_views(approvals: Vec<Approval>) -> Vec<ApprovalView> {
|
||||||
sha_short: sha,
|
sha_short: sha,
|
||||||
diff: None,
|
diff: None,
|
||||||
description: a.description,
|
description: a.description,
|
||||||
|
pr_number,
|
||||||
requested_at: a.requested_at,
|
requested_at: a.requested_at,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue