Skip to content

Instantly share code, notes, and snippets.

@dtudury
Last active December 20, 2015 02:59
Show Gist options
  • Save dtudury/6060115 to your computer and use it in GitHub Desktop.
Save dtudury/6060115 to your computer and use it in GitHub Desktop.
little nagging git hook to remind me to reference a JIRA ticket
#!/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