Skip to content

Commit

Permalink
feat(release): add support for breaking changes commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit committed Jan 12, 2021
1 parent 05314c0 commit b0f4277
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/format/angular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub fn print_conventional_commit_release<W: Write>(
.iter()
.filter(|c| c.commit_type == CCT::Test)
.collect();
let breaking: Vec<&CC> = commits.iter().filter(|c| c.breaking).collect();

if let Some(date) = date {
writeln!(w, "{} ({})", tag.h1(), date)?;
Expand Down Expand Up @@ -139,6 +140,13 @@ pub fn print_conventional_commit_release<W: Write>(
writeln!(w, "{}", c.markdown(&opts).list())?;
}
}
if !breaking.is_empty() && opts.show_all {
let header = opts.emoji(":warning: ").add("BREAKING CHANGES");
writeln!(w, "\n{}\n", header.h3())?;
for c in &breaking {
writeln!(w, "{}", c.markdown(&opts).list())?;
}
}

writeln!(w, "")
}
5 changes: 4 additions & 1 deletion src/parser/conventional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ use crate::format::formatters::Markdown;
use crate::format::FormatOptions;
use crate::git::Commit;
use regex::Regex;
use std::ops::Add;

lazy_static! {
static ref SUMMARY_REGEX: Regex =
Regex::new("^(?P<type>fix|feat|perf|revert|build|chore|ci|docs|style|refactor|test)(?:\\((?P<scope>.*)\\))?: (?P<summary>.*)$").unwrap();
Regex::new("^(?P<type>fix|feat|perf|revert|build|chore|ci|docs|style|refactor|test)(?:\\((?P<scope>.*)\\))?(?P<breaking>!)?: (?P<summary>.*)$").unwrap();
}

#[derive(Debug, Clone)]
Expand All @@ -14,6 +15,7 @@ pub struct ConventionalCommit {
pub scope: Option<String>,
pub summary: String,
pub commit_type: ConventionalCommitType,
pub breaking: bool,
}

impl std::convert::TryFrom<Commit> for ConventionalCommit {
Expand All @@ -31,6 +33,7 @@ impl std::convert::TryFrom<Commit> for ConventionalCommit {
scope: matches.name("scope").map(|s| s.as_str().to_string()),
summary: summary.unwrap().as_str().to_string(),
commit_type: ConventionalCommitType::try_from(commit_type.unwrap().as_str())?,
breaking: matches.name("breaking").is_some(),
})
} else {
Err(format!(
Expand Down

0 comments on commit b0f4277

Please sign in to comment.