Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
refactor: simplify creating Result::Trigger
Lars Wirzenius committed 1 year ago
commit b1820f3c2adbcb8523ed5085557c5739cbe4914f
parent 3a9f8ff3e2e52aebf97f1b4889d9b38445a6b594
1 file changed +23 -25
modified src/msg.rs
@@ -153,37 +153,35 @@ impl<'a> RequestBuilder<'a> {
            }
        };

-
        let (event_type, push, patch) = match parse_ref(name) {
-
            None => Err(MessageError::NoEventHandler)?,
-
            Some(ParsedRef::Patch(_oid)) => (
-
                EventType::Patch,
-
                None,
-
                Some(self.build_trigger_from_patch(event, repository, &repo, profile, author)?),
-
            ),
-
            Some(ParsedRef::Push(_branch)) => (
-
                EventType::Push,
-
                Some(self.build_trigger_from_push(
+
        match parse_ref(name) {
+
            None => Err(MessageError::NoEventHandler),
+
            Some(ParsedRef::Patch(_oid)) => Ok(Request::Trigger {
+
                common: EventCommonFields {
+
                    version: PROTOCOL_VERSION,
+
                    event_type: EventType::Patch,
+
                    repository: msg_repository,
+
                },
+
                push: None,
+
                patch: Some(
+
                    self.build_trigger_from_patch(event, repository, &repo, profile, author)?,
+
                ),
+
            }),
+
            Some(ParsedRef::Push(_branch)) => Ok(Request::Trigger {
+
                common: EventCommonFields {
+
                    version: PROTOCOL_VERSION,
+
                    event_type: EventType::Push,
+
                    repository: msg_repository,
+
                },
+
                push: Some(self.build_trigger_from_push(
                    repo,
                    author,
                    name,
                    old.unwrap_or(*oid),
                    *oid,
                )?),
-
                None,
-
            ),
-
        };
-

-
        let common = EventCommonFields {
-
            version: PROTOCOL_VERSION,
-
            event_type,
-
            repository: msg_repository,
-
        };
-

-
        Ok(Request::Trigger {
-
            common,
-
            push,
-
            patch,
-
        })
+
                patch: None,
+
            }),
+
        }
    }

    fn build_trigger_from_patch(