Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(updater): Add changelog to nightly update provider
- Loading branch information
Showing
7 changed files
with
251 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
function mergeAndSortCategories(merges, fixes, commits) { | ||
const allCommits = [ | ||
...merges.map(merge => merge.commit), | ||
...fixes.map(merge => merge.commit), | ||
...commits | ||
]; | ||
|
||
allCommits.forEach(commit => { | ||
commit.breaking = /^[A-Za-z0-9.]+!(?:\(.*\))?:/.test(commit.subject); | ||
}) | ||
|
||
return allCommits.sort((a, b) => { | ||
return new Date(b.date) - new Date(a.date); | ||
}); | ||
} | ||
|
||
module.exports = function (Handlebars) { | ||
Handlebars.registerHelper('get-all-non-breaking-commits', function (merges, fixes, commits) { | ||
return mergeAndSortCategories(merges, fixes, commits).filter(c => c.breaking === false); | ||
}) | ||
|
||
Handlebars.registerHelper('get-all-breaking-commits', function (merges, fixes, commits) { | ||
return mergeAndSortCategories(merges, fixes, commits).filter(c => c.breaking === true); | ||
}) | ||
|
||
Handlebars.registerHelper("render-ccm", function(subject) { | ||
const match = /^(?<type>[A-Za-z0-9.]+)(?<breaking>!)?(?:\((?<scope>[A-Za-z0-9.]+)\))?: (?<message>.*)$/.exec(subject); | ||
|
||
if (typeof match?.groups?.type === "string" && typeof match?.groups?.message === "string") { | ||
let output = match.groups.message; | ||
|
||
if (typeof match.groups.scope === "string") { | ||
output = `**${match.groups.scope}**: ${output}`; | ||
} | ||
|
||
return output; | ||
} else { | ||
return subject; | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{#with releases.[0]}} | ||
{{#if tag}} | ||
## Valetudo {{tag}} ({{date}}) | ||
{{else}} | ||
## Valetudo nightly ({{date}}) | ||
{{/if}} | ||
{{#commit-list (get-all-breaking-commits merges fixes commits) heading='### Breaking Changes'}} | ||
- {{render-ccm subject}} [`{{shorthash}}`]({{href}}) | ||
{{/commit-list}} | ||
|
||
{{#commit-list (get-all-non-breaking-commits merges fixes commits) heading='### Features' message='^feat!?(?:\(.*\))?:'}} | ||
- {{render-ccm subject}} [`{{shorthash}}`]({{href}}) | ||
{{/commit-list}} | ||
|
||
{{#commit-list (get-all-non-breaking-commits merges fixes commits) heading='### Fixes' message='^fix!?(?:\(.*\))?:'}} | ||
- {{render-ccm subject}} [`{{shorthash}}`]({{href}}) | ||
{{/commit-list}} | ||
|
||
{{#commit-list (get-all-non-breaking-commits merges fixes commits) heading='### Refactoring' message='^refactor!?(?:\(.*\))?:'}} | ||
- {{render-ccm subject}} [`{{shorthash}}`]({{href}}) | ||
{{/commit-list}} | ||
|
||
{{#commit-list (get-all-non-breaking-commits merges fixes commits) heading='### Chores' message='^chore!?(?:\(.*\))?:'}} | ||
- {{render-ccm subject}} [`{{shorthash}}`]({{href}}) | ||
{{/commit-list}} | ||
{{/with}} |