From 4199a71e6fbaf905f87909357c31fbed1b5012a4 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 29 Jan 2026 19:59:27 +0000 Subject: [PATCH] Initial commit: git-issue-commit CLI tool --- src/parser/conventional.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/parser/conventional.rs diff --git a/src/parser/conventional.rs b/src/parser/conventional.rs new file mode 100644 index 0000000..526c626 --- /dev/null +++ b/src/parser/conventional.rs @@ -0,0 +1,36 @@ +use serde::Serialize; + +#[derive(Debug, Clone, Default)] +pub struct ConventionalMessage { + pub r#type: String, + pub scope: Option, + pub description: String, + pub body: Option, + pub breaking: bool, + pub breaking_description: Option, + pub footer: Option, +} + +impl ConventionalMessage { + pub fn header(&self) -> String { + let scope_part = self.scope.as_ref() + .map(|s| format!("({})", s)) + .unwrap_or_default(); + + let breaking_marker = if self.breaking { "!" } else { "" }; + + let description = if self.description.trim().is_empty() { + "no description".to_string() + } else { + self.description.clone() + }; + + format!( + "{}{}{}: {}", + self.r#type, + scope_part, + breaking_marker, + description + ) + } +}