Created
December 18, 2015 08:56
-
-
Save yurenju/f0615da030d18dfdbe3b to your computer and use it in GitHub Desktop.
prepare-commit-msg
This file contains hidden or 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
#!/usr/bin/env node | |
/** | |
* This git hook requires shelljs, please use |npm install shelljs --save-dev| | |
* to install it. | |
*/ | |
require('shelljs/global'); | |
var issueNum; | |
var msg; | |
var file = process.argv[2]; | |
var branch = exec('git rev-parse --abbrev-ref HEAD').output; | |
var matched = branch.match(/-*(\d+)-*/); | |
var type = process.argv[3]; | |
if (type) return exit(0); | |
// comment message for git status | |
var status = exec('git status').output.split('\n') | |
.map(function(line) { return '# ' + line; }) | |
.join('\n'); | |
if (matched) { | |
issueNum = matched[1]; | |
msg = 'Fixed #' + issueNum + ': \n\n' + status; | |
msg.to(file); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment