Skip to content

Commit

Permalink
refactor(config): make tag_pattern optional
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jun 17, 2021
1 parent 076fc85 commit 3a27a3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion git-cliff-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct GitConfig {
/// Whether to filter out commits.
pub filter_commits: Option<bool>,
/// Blob pattern for git tags.
pub tag_pattern: String,
pub tag_pattern: Option<String>,
#[serde(with = "serde_regex", default)]
/// Regex to skip matched tags.
pub skip_tags: Option<Regex>,
Expand Down
7 changes: 5 additions & 2 deletions git-cliff-core/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ impl Repository {
/// Parses and returns a commit-tag map.
///
/// It collects lightweight and annotated tags.
pub fn tags(&self, pattern: &str) -> Result<IndexMap<String, String>> {
pub fn tags(
&self,
pattern: &Option<String>,
) -> Result<IndexMap<String, String>> {
let mut tags = IndexMap::new();
let tag_names = self.inner.tag_names(Some(pattern))?;
let tag_names = self.inner.tag_names(pattern.as_deref())?;
for name in tag_names.iter().flatten().map(String::from) {
let obj = self.inner.revparse_single(&name)?;
if let Ok(commit) = obj.clone().into_commit() {
Expand Down

0 comments on commit 3a27a3e

Please sign in to comment.