Extract PushEvent::updated_refs for non-deleted refs
The all-zero SHA deletion check is now in one place instead of
duplicated across dispatch_ci and dispatch_mirror.

Assisted-by: GLM-5.1 via pi
change msplowupxylonulsylmzuxuynxvxukwq
commit 6f9770eb68ab90c501562fb44d4b39cac07a757d
author Alpha Chen <alpha@kejadlen.dev>
date
parent rpxvvryq
diff --git a/src/event.rs b/src/event.rs
index 5c2da06..8fc894e 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -37,12 +37,7 @@ pub async fn dispatch_push(quire: &crate::Quire, event: &PushEvent) {
 fn dispatch_ci(repo: &crate::quire::Repo, event: &PushEvent) {
     use crate::ci::{RunMeta, RunState, RunStateFile};
 
-    for push_ref in &event.refs {
-        // Skip deletions (all-zero new sha).
-        if push_ref.new_sha == "0000000000000000000000000000000000000000" {
-            continue;
-        }
-
+    for push_ref in event.updated_refs() {
         if !repo.has_ci_fnl(&push_ref.new_sha) {
             continue;
         }
@@ -138,9 +133,8 @@ async fn dispatch_mirror(quire: &crate::Quire, repo: crate::quire::Repo, event:
 
     // Only push refs that were actually updated (non-zero new sha).
     let refs: Vec<String> = event
-        .refs
+        .updated_refs()
         .iter()
-        .filter(|r| r.new_sha != "0000000000000000000000000000000000000000")
         .map(|r| r.r#ref.clone())
         .collect();
 
@@ -181,6 +175,14 @@ impl PushEvent {
             refs,
         }
     }
+
+    /// Refs that are not deletions (non-zero new sha).
+    pub fn updated_refs(&self) -> Vec<&PushRef> {
+        self.refs
+            .iter()
+            .filter(|r| r.new_sha != "0000000000000000000000000000000000000000")
+            .collect()
+    }
 }
 
 #[cfg(test)]