-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build changelog from git commit history whenever bumping a version
- Loading branch information
1 parent
51c95e8
commit c9af8ec
Showing
2 changed files
with
44 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var gulp = require('gulp'), | ||
util = require('gulp-util'), | ||
cat = require('gulp-cat'), | ||
git = require('gulp-git'), | ||
replace = require('gulp-replace'), | ||
path = require('path'); | ||
|
||
var repo = require('../package.json').repository.url; | ||
|
||
gulp.task('changelog', function(done) { | ||
git.exec({ args: 'log --oneline --decorate' }, function(err, stdout) { | ||
if(err) return done(err); | ||
return done(null, gulp.src('CHANGELOG.md') | ||
.pipe(replace(/.|\n/g, '')) | ||
.pipe(replace(/$/, stdout)) | ||
.pipe(replace(/#(\d+)/, '[#$1](' + repo + '/issues/$1)')) | ||
.pipe(replace(/([a-f0-9]{7}) \(HEAD[^)]*\) (.+)/g, function(_, sha, comment) { | ||
return '\n## [Working Changes](' + repo + ')' + | ||
'\n- [' + sha + '](' + repo + '/commit/' + sha + ') ' + comment; | ||
})) | ||
.pipe(replace(/([a-f0-9]{7}) \(tag: ([^\s),]*)[^)]*\) (.+)/g, function(_, sha, tag, comment) { | ||
var niceTag = tag; | ||
if(tag.indexOf('v') !== 0) niceTag = 'v' + tag; | ||
return '\n## [' + niceTag + '](' + repo + '/tree/' + tag + ')' + | ||
'\n- [' + sha + '](' + repo + '/commit/' + sha + ') ' + comment; | ||
})) | ||
.pipe(replace(/([a-f0-9]{7}) (.+)/g, '- [$1](' + repo + '/commit/$1) $2')) | ||
.pipe(gulp.dest('.'))); | ||
}); | ||
}); | ||
|
||
gulp.task('changelog-commit', function () { | ||
return gulp.src('.') | ||
.pipe(git.commit('Updated CHANGELOG')); | ||
}); |
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