Initial commit: git-issue-commit CLI tool
This commit is contained in:
36
src/parser/conventional.rs
Normal file
36
src/parser/conventional.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ConventionalMessage {
|
||||
pub r#type: String,
|
||||
pub scope: Option<String>,
|
||||
pub description: String,
|
||||
pub body: Option<String>,
|
||||
pub breaking: bool,
|
||||
pub breaking_description: Option<String>,
|
||||
pub footer: Option<String>,
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user