style: 格式化代码并优化导入顺序
This commit is contained in:
@@ -10,7 +10,7 @@ pub fn format_conventional_commit(
|
||||
breaking: bool,
|
||||
) -> String {
|
||||
let mut message = String::new();
|
||||
|
||||
|
||||
message.push_str(commit_type);
|
||||
if let Some(s) = scope {
|
||||
message.push_str(&format!("({})", s));
|
||||
@@ -19,15 +19,15 @@ pub fn format_conventional_commit(
|
||||
message.push('!');
|
||||
}
|
||||
message.push_str(&format!(": {}", description));
|
||||
|
||||
|
||||
if let Some(b) = body {
|
||||
message.push_str(&format!("\n\n{}", b));
|
||||
}
|
||||
|
||||
|
||||
if let Some(f) = footer {
|
||||
message.push_str(&format!("\n\n{}", f));
|
||||
}
|
||||
|
||||
|
||||
message
|
||||
}
|
||||
|
||||
@@ -41,27 +41,27 @@ pub fn format_commitlint_commit(
|
||||
references: Option<&[&str]>,
|
||||
) -> String {
|
||||
let mut message = String::new();
|
||||
|
||||
|
||||
message.push_str(commit_type);
|
||||
if let Some(s) = scope {
|
||||
message.push_str(&format!("({})", s));
|
||||
}
|
||||
message.push_str(&format!(": {}", subject));
|
||||
|
||||
|
||||
if let Some(refs) = references {
|
||||
for reference in refs {
|
||||
message.push_str(&format!(" #{}", reference));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if let Some(b) = body {
|
||||
message.push_str(&format!("\n\n{}", b));
|
||||
}
|
||||
|
||||
|
||||
if let Some(f) = footer {
|
||||
message.push_str(&format!("\n\n{}", f));
|
||||
}
|
||||
|
||||
|
||||
message
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ pub fn wrap_text(text: &str, width: usize) -> String {
|
||||
/// Clean commit message (remove comments, extra whitespace)
|
||||
pub fn clean_message(message: &str) -> String {
|
||||
let comment_regex = Regex::new(r"^#.*$").unwrap();
|
||||
|
||||
|
||||
message
|
||||
.lines()
|
||||
.filter(|line| !comment_regex.is_match(line.trim()))
|
||||
@@ -97,7 +97,7 @@ mod tests {
|
||||
Some("Closes #123"),
|
||||
false,
|
||||
);
|
||||
|
||||
|
||||
assert!(msg.contains("feat(auth): add login functionality"));
|
||||
assert!(msg.contains("This adds OAuth2 login support."));
|
||||
assert!(msg.contains("Closes #123"));
|
||||
@@ -113,7 +113,7 @@ mod tests {
|
||||
Some("BREAKING CHANGE: response format changed"),
|
||||
true,
|
||||
);
|
||||
|
||||
|
||||
assert!(msg.starts_with("feat!: change API response format"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user