fix(#2417): accept forgejo's 'synchronized' pr-update webhook action
This commit is contained in:
parent
4545dd312e
commit
d90504b427
1 changed files with 12 additions and 6 deletions
|
|
@ -124,13 +124,14 @@ pub(super) async fn post_webhook_knowledge(
|
||||||
/// Minimal Forgejo `pull_request`-webhook payload.
|
/// Minimal Forgejo `pull_request`-webhook payload.
|
||||||
///
|
///
|
||||||
/// Forgejo fires this for actions: `opened`, `closed`, `reopened`,
|
/// Forgejo fires this for actions: `opened`, `closed`, `reopened`,
|
||||||
/// `synchronize`, `assigned`, `unassigned`, `label_updated`,
|
/// `synchronized`, `assigned`, `unassigned`, `label_updated`,
|
||||||
/// `label_cleared`, `milestoned`, `demilestoned`, `review_requested`,
|
/// `label_cleared`, `milestoned`, `demilestoned`, `review_requested`,
|
||||||
/// `review_request_removed`, `auto_merge_enabled`, `auto_merge_disabled`.
|
/// `review_request_removed`, `auto_merge_enabled`, `auto_merge_disabled`.
|
||||||
/// We only act on `opened` and `synchronize`.
|
/// We only act on `opened` and `synchronized` (Forgejo spells the
|
||||||
|
/// push-update action past-tense, unlike GitHub's `synchronize`).
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub(super) struct PrWebhookPayload {
|
pub(super) struct PrWebhookPayload {
|
||||||
/// What triggered this event (`opened`, `closed`, `synchronize`, …).
|
/// What triggered this event (`opened`, `closed`, `synchronized`, …).
|
||||||
action: Option<String>,
|
action: Option<String>,
|
||||||
/// PR index on the repo.
|
/// PR index on the repo.
|
||||||
number: Option<u64>,
|
number: Option<u64>,
|
||||||
|
|
@ -156,7 +157,7 @@ struct PrWebhookRepo {
|
||||||
/// POST `/webhook/config-pr` — Forgejo `pull_request` webhook for
|
/// POST `/webhook/config-pr` — Forgejo `pull_request` webhook for
|
||||||
/// `agent-configs/*` repos.
|
/// `agent-configs/*` repos.
|
||||||
///
|
///
|
||||||
/// On `opened` or `synchronize` for an `agent-configs/<agent>` PR:
|
/// On `opened` or `synchronized` for an `agent-configs/<agent>` PR:
|
||||||
/// fetches the current PR head sha, queues a `MergeConfigPr` approval row,
|
/// fetches the current PR head sha, queues a `MergeConfigPr` approval row,
|
||||||
/// and emits the `ApprovalAdded` event so the dashboard card appears
|
/// and emits the `ApprovalAdded` event so the dashboard card appears
|
||||||
/// immediately.
|
/// immediately.
|
||||||
|
|
@ -200,8 +201,13 @@ pub(super) async fn post_webhook_config_pr(
|
||||||
};
|
};
|
||||||
|
|
||||||
let action = payload.action.as_deref().unwrap_or("");
|
let action = payload.action.as_deref().unwrap_or("");
|
||||||
// Only act on newly-opened or force-updated PRs.
|
// Only act on a newly-opened PR or a new push to its branch. Forgejo's
|
||||||
if action != "opened" && action != "synchronize" {
|
// webhook payload spells the push-update action `synchronized` (past
|
||||||
|
// tense), NOT GitHub's `synchronize` — matching only the GitHub spelling
|
||||||
|
// silently dropped every PR-update delivery (the whole reason updates were
|
||||||
|
// "only found by poll"). Accept both so the handler is correct against
|
||||||
|
// Forgejo and stays GitHub-compatible.
|
||||||
|
if action != "opened" && action != "synchronize" && action != "synchronized" {
|
||||||
tracing::debug!(action, "webhook/config-pr: ignoring action");
|
tracing::debug!(action, "webhook/config-pr: ignoring action");
|
||||||
return (StatusCode::OK, "ignored").into_response();
|
return (StatusCode::OK, "ignored").into_response();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue