Skip to content

Commit

Permalink
fix(changelog): fixes whitespace issues
Browse files Browse the repository at this point in the history
Probabaly not perfect yet, but at least much better than before.

Refs: #20
  • Loading branch information
hdevalke committed Aug 26, 2021
1 parent 0e99770 commit 91b5b72
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 59 deletions.
12 changes: 6 additions & 6 deletions src/conventional/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ pub(crate) struct Reference<'a> {
pub(crate) raw: String,
}

#[derive(Serialize)]
#[derive(Debug, Serialize)]
pub(crate) struct Note {
pub(crate) scope: Option<String>,
pub(crate) text: String,
}

#[derive(Serialize)]
#[derive(Debug, Serialize)]
pub(crate) struct NoteGroup {
pub(crate) title: String,
pub(crate) notes: Vec<Note>,
}

#[derive(Serialize)]
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct CommitContext<'a> {
pub(crate) hash: String,
Expand All @@ -46,13 +46,13 @@ pub(crate) struct CommitContext<'a> {
pub(crate) references: Vec<Reference<'a>>,
}

#[derive(Serialize)]
#[derive(Debug, Serialize)]
pub(crate) struct CommitGroup<'a> {
pub(crate) title: &'a str,
pub(crate) commits: Vec<CommitContext<'a>>,
}

#[derive(Serialize)]
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct Context<'a> {
#[serde(flatten)]
Expand All @@ -65,7 +65,7 @@ pub(crate) struct Context<'a> {
/// `true` if `previousTag` and `currentTag` are truthy.
pub(crate) link_compare: bool,
}
#[derive(Serialize)]
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ContextBase<'a> {
pub(crate) version: &'a str,
Expand Down
31 changes: 6 additions & 25 deletions src/conventional/changelog/commit.hbs
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
*{{#if scope}} **{{scope}}:**
{{~/if}} {{#if subject}}
{{~subject}}
{{~else}}
{{~header}}
{{~/if~}}

{{~#if @root.linkReferences}} ([{{shortHash}}]({{commitUrlFormat}}))
{{~else}} {{shortHash}}
{{~/if~}}

{{~#if references~}}
, closes
{{~#each references}} {{#if @root.linkReferences~}}
[
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}{{this.prefix}}{{this.issue}}]({{issueUrlFormat}})
{{~else}}
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}{{this.prefix}}{{this.issue}}
{{~/if}}{{/each}}
*{{#if scope}} **{{scope}}:**{{/if}} {{#if subject}}{{subject}}{{else}}{{header}}{{/if}}
{{~#if hash}}
{{~#if @root.linkReferences}} ([{{shortHash}}]({{commitUrlFormat}}))
{{~else}} {{shortHash}}{{/if}}
{{~/if}}

{{#if references}}, closes{{#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{this.prefix}}{{this.issue}}]({{issueUrlFormat}}){{else}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{this.prefix}}{{this.issue}}{{/if}}{{/each}}{{/if}}
14 changes: 1 addition & 13 deletions src/conventional/changelog/header.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
{{~#if isPatch~}}
###
{{~else~}}
##
{{~/if}} {{#if @root.linkCompare~}}
[{{version}}]({{compareUrlFormat}})
{{~else}}
{{~version}}
{{~/if}}
{{~#if title}} "{{title}}"
{{~/if}}
{{~#if date}} ({{date}})
{{~/if}}

{{#if isPatch}}###{{else}}##{{/if}} {{#if @root.linkCompare}}[{{version}}]({{compareUrlFormat}}){{else}} {{version}}{{/if}}{{#if title}} "{{title}}"{{/if}}{{#if date}} ({{date}}){{/if}}
27 changes: 12 additions & 15 deletions src/conventional/changelog/template.hbs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{{~> header~}}

{{#if noteGroups~}}
{{~#each noteGroups~}}
{{> header}}
{{#if noteGroups}}
{{#each noteGroups}}

### ⚠ {{title}}

{{#each notes~}}
* {{#if this.scope}}**{{this.scope}}:** {{/if}}{{text}}
{{#each notes}}
* {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}}
{{/each}}
{{/each}}
{{~/each}}
{{/if}}
{{~#each commitGroups~}}

{{#if @root.isPatch}}####{{else}}###{{/if}} {{title}}

{{#each commits~}}
{{> commit root=@root~}}
{{~/each}}
{{/each~}}
{{#each commitGroups}}
{{#if title}}{{#if @root.isPatch}}####{{else}}###{{/if}} {{title}}{{/if}}

{{> footer}}
{{#each commits}}
{{> commit root=@root}}
{{/each}}
{{/each}}

0 comments on commit 91b5b72

Please sign in to comment.