feat(pre): add option to provide own commit message analyzer

This commit is contained in:
Stephan Bönnemann
2015-04-22 17:15:10 +02:00
parent 29469e0b8a
commit e445effdcf
6 changed files with 53 additions and 31 deletions
+13 -1
View File
@@ -1,9 +1,21 @@
'use strict'
var parseRawCommit = require('conventional-changelog/lib/git').parseRawCommit
module.exports = function (commits) {
var type = null
commits.every(function (commit) {
commits
.map(function (commit) {
return parseRawCommit(commit.hash + '\n' + commit.message)
})
.filter(function (commit) {
return !!commit
})
.every(function (commit) {
if (commit.breaks.length) {
type = 'major'
return false
+27
View File
@@ -0,0 +1,27 @@
'use strict'
var exec = require('child_process').exec
var efh = require('./error').efh
module.exports = function (from, cb) {
var range = (from ? from + '..' : '') + 'HEAD'
exec(
'git log -E --format=%H==SPLIT==%s==END== ' + range,
efh(cb)(function (stdout) {
cb(null, String(stdout).split('==END==\n')
.filter(function (raw) {
return !!raw.trim()
})
.map(function (raw) {
var data = raw.split('==SPLIT==')
return {
hash: data[0],
message: data[1]
}
}))
})
)
}
-15
View File
@@ -1,15 +0,0 @@
'use strict'
var git = require('conventional-changelog/lib/git')
var efh = require('../error').efh
module.exports = function (from, cb) {
git.getCommits({
log: console.log.bind(console),
warn: console.warn.bind(console),
from: from
}, efh(cb)(function (commits) {
cb(null, commits)
}))
}
-11
View File
@@ -1,11 +0,0 @@
'use strict'
var analyze = require('./analyze')
var commits = require('./commits')
var efh = require('../error').efh
module.exports = function (gitHead, cb) {
commits(gitHead, efh(cb)(function (commits) {
cb(null, analyze(commits))
}))
}