Skip to main content

releasaurus_core/analyzer/
config.rs

1//! Configuration for changelog generation and commit analysis.
2
3use derive_builder::Builder;
4use regex::Regex;
5use url::Url;
6
7use crate::config::{prerelease::PrereleaseConfig, resolved::CommitModifiers};
8
9/// Configuration for commit analysis and changelog generation.
10#[derive(Debug, Clone, Builder)]
11#[builder(setter(into, strip_option), default)]
12pub struct AnalyzerConfig {
13    /// Tera template string for changelog body format.
14    pub body: String,
15    /// Skips including ci commits in changelog (default: false)
16    pub skip_ci: bool,
17    /// Skips including chore commits in changelog (default: false)
18    pub skip_chore: bool,
19    /// Skips including doc commits in changelog (default: false)
20    pub skip_doc: bool,
21    /// Skips including test commits in changelog (default: false)
22    pub skip_test: bool,
23    /// Skips including style commits in changelog (default: false)
24    pub skip_style: bool,
25    /// Skips including refactor commits in changelog (default: false)
26    pub skip_refactor: bool,
27    /// Skips including perf commits in changelog (default: false)
28    pub skip_perf: bool,
29    /// Skips including revert commits in changelog (default: false)
30    pub skip_revert: bool,
31    /// Skips including miscellaneous commits in changelog (default: false)
32    pub skip_miscellaneous: bool,
33    /// Skips including merge commits in changelog (default: true)
34    pub skip_merge_commits: bool,
35    /// Includes commit author in default body template (default: false)
36    pub include_author: bool,
37    /// Optional prefix for package tags.
38    pub tag_prefix: Option<String>,
39    /// Base URL for release links in changelog.
40    pub release_link_base_url: Option<Url>,
41    /// Base URL for comparing releases and showing diffs
42    pub compare_link_base_url: Option<Url>,
43    /// Prerelease settings (if enabled).
44    pub prerelease: Option<PrereleaseConfig>,
45    /// regex to match and exclude release commits
46    pub release_commit_matcher: Option<Regex>,
47    /// Always increments major version on breaking commits
48    pub breaking_always_increment_major: bool,
49    /// Always increments minor version on feature commits
50    pub features_always_increment_minor: bool,
51    /// Custom commit type regex matcher to increment major version
52    pub custom_major_increment_regex: Option<String>,
53    /// Custom commit type regex matcher to increment minor version
54    pub custom_minor_increment_regex: Option<String>,
55    /// Custom commit modifiers to skip commit shas or reword commit messages
56    /// when generating changelog content
57    pub commit_modifiers: CommitModifiers,
58}
59
60impl Default for AnalyzerConfig {
61    fn default() -> Self {
62        Self {
63            body: "".into(),
64            skip_ci: false,
65            skip_chore: false,
66            skip_doc: false,
67            skip_test: false,
68            skip_style: false,
69            skip_refactor: false,
70            skip_perf: false,
71            skip_revert: false,
72            skip_miscellaneous: false,
73            skip_merge_commits: true,
74            include_author: false,
75            tag_prefix: None,
76            release_link_base_url: None,
77            compare_link_base_url: None,
78            prerelease: None,
79            release_commit_matcher: None,
80            breaking_always_increment_major: true,
81            features_always_increment_minor: true,
82            custom_major_increment_regex: None,
83            custom_minor_increment_regex: None,
84            commit_modifiers: CommitModifiers::default(),
85        }
86    }
87}