Skip to content

Commit 2ff24fc

Browse files
committed
Changelog: Use changelogplease for git parsing
Fixes gh-7 Closes gh-53
1 parent 089e3d1 commit 2ff24fc

File tree

12 files changed

+975
-40
lines changed

12 files changed

+975
-40
lines changed

lib/changelog.js

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
var fs = require( "fs" );
1+
var fs = require( "fs" ),
2+
changelogplease = require( "changelogplease" );
23

34
module.exports = function( Release ) {
45

56
Release.define({
6-
_generateChangelog: function() {
7-
var changelogPath = Release.dir.base + "/changelog",
8-
changelog = Release.changelogShell() +
9-
Release._generateCommitChangelog() +
10-
Release._generateIssueChangelog();
11-
12-
fs.writeFileSync( changelogPath, changelog );
13-
console.log( "Stored changelog in " + changelogPath.cyan + "." );
7+
_generateChangelog: function( callback ) {
8+
Release._generateCommitChangelog(function( commitChangelog ) {
9+
var changelogPath = Release.dir.base + "/changelog",
10+
changelog = Release.changelogShell() +
11+
commitChangelog +
12+
Release._generateIssueChangelog();
13+
14+
fs.writeFileSync( changelogPath, changelog );
15+
console.log( "Stored changelog in " + changelogPath.cyan + "." );
16+
callback();
17+
});
1418
},
1519

1620
changelogShell: function() {
@@ -21,39 +25,21 @@ Release.define({
2125
return Release.newVersion;
2226
},
2327

24-
_generateCommitChangelog: function() {
25-
var commits,
26-
commitRef = "[%h](" + Release._repositoryUrl() + "/commit/%H)",
27-
fullFormat = "* %s (TICKETREF, " + commitRef + ")",
28-
ticketUrl = Release._ticketUrl();
29-
28+
_generateCommitChangelog: function( callback ) {
3029
console.log( "Adding commits..." );
31-
Release.chdir( Release.dir.repo );
32-
commits = Release.gitLog( fullFormat );
33-
34-
console.log( "Adding links to tickets..." );
35-
return commits
36-
37-
// Add ticket references
38-
.map(function( commit ) {
39-
var tickets = [];
40-
41-
commit.replace( /Fix(?:e[sd])? #(\d+)/g, function( match, ticket ) {
42-
tickets.push( ticket );
43-
});
44-
45-
return tickets.length ?
46-
commit.replace( "TICKETREF", tickets.map(function( ticket ) {
47-
return "[#" + ticket + "](" + ticketUrl + ticket + ")";
48-
}).join( ", " ) ) :
49-
50-
// Leave TICKETREF token in place so it's easy to find commits without tickets
51-
commit;
52-
})
5330

54-
// Sort commits so that they're grouped by component
55-
.sort()
56-
.join( "\n" ) + "\n";
31+
changelogplease({
32+
ticketUrl: Release._ticketUrl() + "{id}",
33+
commitUrl: Release._repositoryUrl() + "/commit/{id}",
34+
repo: Release.dir.repo,
35+
committish: Release.prevVersion + ".." + Release.newVersion
36+
}, function( error, log ) {
37+
if ( error ) {
38+
Release.abort( "Error generating commit changelog.", error );
39+
}
40+
41+
callback( log );
42+
});
5743
},
5844

5945
_generateIssueChangelog: function() {

node_modules/changelogplease/.npmignore

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/changelogplease/LICENSE.txt

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/changelogplease/README.md

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/changelogplease/index.js

Lines changed: 107 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/changelogplease/node_modules/git-tools/.npmignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/changelogplease/node_modules/git-tools/LICENSE-MIT.txt

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)