Last active
December 20, 2015 02:59
-
-
Save dtudury/6060115 to your computer and use it in GitHub Desktop.
little nagging git hook to remind me to reference a JIRA ticket
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 | |
//install this script from the root of the local repo with something like... | |
//mkdir -p .git/hooks ; curl -L https://gist.github.com/dtudury/6060115/raw > .git/hooks/commit-msg ; chmod +x .git/hooks/commit-msg | |
var fs = require('fs'); | |
//0 is "node", 1 is the path to this script, 2 is the commit message | |
var commit = fs.readFileSync(process.argv[2]).toString(); | |
if(!/\b[A-Z][A-Z]+-[0-9]+\b/.test(commit) && !/^Merge /.test(commit)) { | |
console.log("[SHAME] no JIRA issue key found in commit"); | |
console.log("[SHAME] to ignore this say --no-verify"); | |
console.log("[SHAME] COMMIT FAILED! NO COMMIT FOR YOU!!!1!"); | |
process.exit(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment