Created
August 22, 2015 00:16
-
-
Save jtwalters/822d7d9c524b4629fc19 to your computer and use it in GitHub Desktop.
Throw this in .git/hooks/commit-msg and chmod +x it.
This file contains 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/local/bin/node | |
/* jshint node:true */ | |
// This hook ensures the commit message includes [ci skip] or [ci run] | |
var fs = require('fs'), | |
spawn = require('child_process').spawn, | |
args = process.argv.slice(2), | |
filePath = args[0], | |
exists = fs.existsSync(filePath), | |
contents = exists && fs.readFileSync(filePath, "utf8"), | |
spawnOptions = {detached: true, stdio: 'ignore'}, | |
say; | |
if (!contents) { | |
console.log('commit-msg hook is confused.'); | |
process.exit(1); | |
} | |
if (!/\[ci (skip|run)\]/.test(contents)) { | |
console.log("No [ci skip] or [ci run] found:\n\n" + contents); | |
say = spawn('say', ['-r170', '-vagnes', 'compuwer says no'], spawnOptions); | |
process.exit(1); | |
} | |
else { | |
say = spawn('say', ['BOOM!!!'], spawnOptions); | |
process.exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment