Skip to content

Commit

Permalink
feat(message): Allow semver with simple commit message
Browse files Browse the repository at this point in the history
Latest simple commit format allows semantic version messages
TAG: latest

closes #70
  • Loading branch information
bahmutov committed Mar 10, 2016
1 parent 02be93d commit 871f985
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -177,6 +177,11 @@ see the messages when committing

This should provide plenty of information to debug the hooks

## Local development

To execute commit message validation, run `npm run demo-commit-message` and vary the
test message to see how the hook validates it.

### Small print

Author: Gleb Bahmutov © 2014
6 changes: 6 additions & 0 deletions bin/commit-msg.js
Original file line number Diff line number Diff line change
@@ -22,13 +22,19 @@ la(check.fn(preGit.printError),
'missing preGit.printError,', Object.keys(preGit));

function checkMessage(msg) {
log('checking commit message:', msg);
const isValid = wizard.validate(msg);
if (!isValid) {
log('invalid commit message', msg);
process.exit(-1);
}
log('valid git commit message');
}

ggit.commitMessage()
.then((msg) => {
return process.env.TEST_GIT_MESSAGE || msg;
})
.then(checkMessage)
.catch((err) => {
// assuming each validator printed the errors?
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
},
"config": {
"pre-git": {
"commit-msg": "simple",
"demo": [
"echo this is command 1",
"echo this is command 2",
@@ -48,7 +49,7 @@
"lazy-ass": "1.3.0",
"require-relative": "0.8.7",
"shelljs": "0.5.3",
"simple-commit-message": "1.1.0",
"simple-commit-message": "2.1.0",
"validate-commit-msg": "1.0.0",
"word-wrap": "1.1.0"
},
@@ -98,6 +99,8 @@
"issues": "git-issues",
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"demo": "DEBUG=pre-git node --harmony src/pre-git.js"
"demo": "DEBUG=pre-git node --harmony src/pre-git.js",
"demo-commit-message": "TEST_GIT_MESSAGE='chore(test): test message' DEBUG=pre-git NODE_PATH=.. node bin/commit-msg.js",
"demo-commit-wizard": "DEBUG=pre-git NODE_PATH=.. node bin/commit-wizard.js"
}
}

0 comments on commit 871f985

Please sign in to comment.