Skip to content

Changelog: Use changelogplease for git parsing #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ need to install dependencies which are only necessary for the release.

Defines new properties and methods to add to the `Release` object.

#### abort( msg )
#### abort( msg [, error ] )

Aborts the release and prints the message.
Aborts the release and prints the message. If an error object is provided, it is
used for the stack trace, otherwise the current call stack is used.

#### exec( command, options )

Expand Down
66 changes: 26 additions & 40 deletions lib/changelog.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
var fs = require( "fs" );
var fs = require( "fs" ),
changelogplease = require( "changelogplease" );

module.exports = function( Release ) {

Release.define({
_generateChangelog: function() {
var changelogPath = Release.dir.base + "/changelog",
changelog = Release.changelogShell() +
Release._generateCommitChangelog() +
Release._generateIssueChangelog();

fs.writeFileSync( changelogPath, changelog );
console.log( "Stored changelog in " + changelogPath.cyan + "." );
_generateChangelog: function( callback ) {
Release._generateCommitChangelog(function( commitChangelog ) {
var changelogPath = Release.dir.base + "/changelog",
changelog = Release.changelogShell() +
commitChangelog +
Release._generateIssueChangelog();

fs.writeFileSync( changelogPath, changelog );
console.log( "Stored changelog in " + changelogPath.cyan + "." );
callback();
});
},

changelogShell: function() {
Expand All @@ -21,39 +25,21 @@ Release.define({
return Release.newVersion;
},

_generateCommitChangelog: function() {
var commits,
commitRef = "[%h](" + Release._repositoryUrl() + "/commit/%H)",
fullFormat = "* %s (TICKETREF, " + commitRef + ")",
ticketUrl = Release._ticketUrl();

_generateCommitChangelog: function( callback ) {
console.log( "Adding commits..." );
Release.chdir( Release.dir.repo );
commits = Release.gitLog( fullFormat );

console.log( "Adding links to tickets..." );
return commits

// Add ticket references
.map(function( commit ) {
var tickets = [];

commit.replace( /Fix(?:e[sd])? #(\d+)/g, function( match, ticket ) {
tickets.push( ticket );
});

return tickets.length ?
commit.replace( "TICKETREF", tickets.map(function( ticket ) {
return "[#" + ticket + "](" + ticketUrl + ticket + ")";
}).join( ", " ) ) :

// Leave TICKETREF token in place so it's easy to find commits without tickets
commit;
})

// Sort commits so that they're grouped by component
.sort()
.join( "\n" ) + "\n";
changelogplease({
ticketUrl: Release._ticketUrl() + "{id}",
commitUrl: Release._repositoryUrl() + "/commit/{id}",
repo: Release.dir.repo,
committish: Release.prevVersion + ".." + Release.newVersion
}, function( error, log ) {
if ( error ) {
Release.abort( "Error generating commit changelog.", error );
}

callback( log );
});
},

_generateIssueChangelog: function() {
Expand Down
11 changes: 8 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ Release.define({
process.chdir( directory );
},

abort: function( msg ) {
var error = new Error();
Error.captureStackTrace( error );
abort: function( msg, error ) {
if ( !error ) {
error = new Error( msg );
Error.captureStackTrace( error, Release.abort );
}

console.log( msg.red );
console.log( "Aborting.".red );
console.log();
console.log( error.stack );

process.exit( 1 );
},

Expand Down
4 changes: 4 additions & 0 deletions node_modules/changelogplease/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions node_modules/changelogplease/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions node_modules/changelogplease/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions node_modules/changelogplease/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading