refactor: make variable have an initial value

Clearer for me.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-06-18 20:36:22 +03:00
parent b4484b946d
commit e842e01ac1
+6 -8
View File
@@ -153,24 +153,22 @@ impl<'a> RequestBuilder<'a> {
}
};
let push_info: Option<PushEvent>;
let patch_info: Option<PatchEvent>;
let mut push: Option<PushEvent> = None;
let mut patch: Option<PatchEvent> = None;
let event_type: EventType;
if let Some(parsed_ref) = parse_ref(name) {
match parsed_ref {
ParsedRef::Patch(_oid) => {
event_type = EventType::Patch;
patch_info = Some(
patch = Some(
self.build_trigger_from_patch(event, repository, &repo, profile, author)?,
);
push_info = None;
}
ParsedRef::Push(_branch) => {
event_type = EventType::Push;
let before_oid: Oid = old.unwrap_or(*oid);
push_info =
push =
Some(self.build_trigger_from_push(repo, author, name, before_oid, *oid)?);
patch_info = None;
}
}
let common = EventCommonFields {
@@ -181,8 +179,8 @@ impl<'a> RequestBuilder<'a> {
Ok(Request::Trigger {
common,
push: push_info,
patch: patch_info,
push,
patch,
})
} else {
Err(MessageError::NoEventHandler)