Skip to content

Commit 3a5785c

Browse files
committed
chore(changelog): Add breaking changes section
1 parent 9e6e969 commit 3a5785c

File tree

2 files changed

+54
-22
lines changed

2 files changed

+54
-22
lines changed

Gruntfile.js

+30-14
Original file line numberDiff line numberDiff line change
@@ -296,34 +296,50 @@ module.exports = function(grunt) {
296296
var done = grunt.task.current.async();
297297
var child = grunt.util.spawn({
298298
cmd:process.platform === 'win32' ? 'git.cmd' : 'git',
299-
args:['log', changeFrom + '..' + changeTo, '--oneline']
299+
args: [
300+
'log',
301+
changeFrom + '..' + changeTo,
302+
'--format=%H%n%s%n%b%n==END=='
303+
]
300304
}, function (err, result, code) {
301305

302-
var changelog = {
303-
chore: {}, demo: {}, docs: {}, feat: {}, fix: {}, refactor: {}, style: {}, test: {}
304-
};
306+
var changelog = {};
307+
function addChange(changeType, component, change) {
308+
if (!changelog[changeType]) {
309+
changelog[changeType] = {};
310+
}
311+
if (!changelog[changeType][component]) {
312+
changelog[changeType][component] = [];
313+
}
314+
changelog[changeType][component].push(change);
315+
}
305316

306317
var COMMIT_MSG_REGEXP = /^(chore|demo|docs|feat|fix|refactor|style|test)\((.+)\):? (.+)$/;
307-
var gitlog = ('' + result).split('\n').reverse();
318+
var gitlog = result.toString().split('\n==END==\n').reverse();
308319

309320
if (code) {
310321
grunt.log.error(err);
311322
done(false);
312323
} else {
313324

314325
gitlog.forEach(function (logItem) {
315-
var sha1 = logItem.slice(0, 7);
316-
var fullMsg = logItem.slice(8);
326+
var lines = logItem.split('\n');
327+
var sha1 = lines.shift().substr(0,8); //Only first 7 of sha1
328+
var subject = lines.shift();
317329

318-
var msgMatches = fullMsg.match(COMMIT_MSG_REGEXP);
330+
var msgMatches = subject.match(COMMIT_MSG_REGEXP);
319331
var changeType = msgMatches[1];
320-
var directive = msgMatches[2];
321-
var directiveMsg = msgMatches[3];
322-
323-
if (!changelog[changeType][directive]) {
324-
changelog[changeType][directive] = [];
332+
var component = msgMatches[2];
333+
var componentMsg = msgMatches[3];
334+
335+
var breaking = logItem.match(/BREAKING CHANGE:([\s\S]*)/);
336+
if (breaking) {
337+
addChange('breaking', component, {
338+
sha1: sha1,
339+
msg: breaking[1]
340+
});
325341
}
326-
changelog[changeType][directive].push({sha1:sha1, msg:directiveMsg});
342+
addChange(changeType, component, {sha1:sha1, msg:componentMsg});
327343
});
328344

329345
console.log(grunt.template.process(grunt.file.read('misc/changelog.tpl.md'), {data: {

misc/changelog.tpl.md

+24-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@
22

33
## Features
44

5-
<% _(changelog.feat).forEach(function(changes, directive) { %>- **<%= directive%>:**
6-
<% changes.forEach(function(change) { %> - <%= change.msg%> ([<%= change.sha1%>](https://github.com/angular-ui/bootstrap/commit/<%= change.sha1%>))
7-
<% }) %><% }) %>
8-
## Bug fixes
9-
10-
<% _(changelog.fix).forEach(function(changes, directive) { %>- **<%= directive%>:**
11-
<% changes.forEach(function(change) { %> - <%= change.msg%> ([<%= change.sha1%>](https://github.com/angular-ui/bootstrap/commit/<%= change.sha1%>))
12-
<% }) %><% }) %>
5+
<% _(changelog.feat).forEach(function(changes, component) { %>
6+
- **<%= component%>:**
7+
<% changes.forEach(function(change) { %>
8+
- <%= change.msg%> ([<%= change.sha1%>](https://github.com/angular-ui/bootstrap/commit/<%= change.sha1%>))
9+
<% }) %>
10+
<% }) %>
11+
12+
## Bug Fixes
13+
14+
<% _(changelog.fix).forEach(function(changes, component) { %>
15+
- **<%= component%>:**
16+
<% changes.forEach(function(change) { %>
17+
- <%= change.msg%> ([<%= change.sha1%>](https://github.com/angular-ui/bootstrap/commit/<%= change.sha1%>))
18+
<% }) %>
19+
<% }) %>
20+
21+
## Breaking Changes
22+
23+
<% _(changelog.breaking).forEach(function(changes, component) { %>
24+
- **<%= component%>:**
25+
<% changes.forEach(function(change) { %>
26+
<%= change.msg%>
27+
<% }) %>
28+
<% }) %>

0 commit comments

Comments
 (0)