use derive_builder::Builder;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
pub const DEFAULT_BODY: &str = r#"# [{{ version }}]{% if tag_compare_link %}({{ tag_compare_link }}){% else %}({{ link }}){% endif %} - {{ timestamp | date(format="%Y-%m-%d") }}
{% for group, commits in commits | filter(attribute="merge_commit", value=false) | sort(attribute="group") | group_by(attribute="group") %}
### {{ group | striptags | trim }}
{% for commit in commits %}
{% if commit.breaking -%}
{% if commit.scope %}_({{ commit.scope }})_ {% endif -%}[**breaking**]: {{ commit.title }} [_({{ commit.short_id }})_]({{ commit.link }}){% if include_author %} ({{ commit.author_name }}){% endif %}
{% if commit.body -%}
> {{ commit.body }}
{% endif -%}
{% if commit.breaking_description -%}
> {{ commit.breaking_description }}
{% endif -%}
{% else -%}
- {% if commit.scope %}_({{ commit.scope }})_ {% endif %}{{ commit.title }} [_({{ commit.short_id }})_]({{ commit.link }}){% if include_author %} ({{ commit.author_name }}){% endif %}
{% endif -%}
{% endfor %}
{% endfor %}
"#;
#[derive(
Debug, Clone, Default, JsonSchema, Serialize, Deserialize, Builder,
)]
#[builder(setter(into))]
pub struct RewordedCommit {
pub sha: String,
pub message: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Builder)]
#[builder(setter(into, strip_option), default)]
#[serde(default)] pub struct ChangelogConfig {
pub body: String,
pub skip_ci: bool,
pub skip_chore: bool,
pub skip_doc: bool,
pub skip_test: bool,
pub skip_style: bool,
pub skip_refactor: bool,
pub skip_perf: bool,
pub skip_revert: bool,
pub skip_miscellaneous: bool,
pub skip_merge_commits: bool,
pub skip_shas: Option<Vec<String>>,
pub reword: Option<Vec<RewordedCommit>>,
pub include_author: bool,
pub aggregate_prereleases: bool,
}
impl Default for ChangelogConfig {
fn default() -> Self {
Self {
body: DEFAULT_BODY.into(),
skip_ci: false,
skip_chore: false,
skip_doc: false,
skip_test: false,
skip_style: false,
skip_refactor: false,
skip_perf: false,
skip_revert: false,
skip_miscellaneous: false,
skip_merge_commits: true,
skip_shas: None,
reword: None,
include_author: false,
aggregate_prereleases: false,
}
}
}