-
-
Save jesseditson/7903823 to your computer and use it in GitHub Desktop.
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 | |
// Copyright 2011, Tim Branyen @tbranyen <[email protected]> | |
// Dual licensed under the MIT and GPL licenses. | |
// Script to detect cursewords in commit messages and provide the | |
// offending commit sha's. | |
// vim: ft=javascript | |
var git = require('nodegit'); | |
var curses = [ 'fuck', 'shit', 'piss', 'cunt', 'cocksucker', 'motherfucker', 'tits', 'bastard' ], | |
path = './.git', | |
branchName = 'master', | |
reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi'); | |
if (process.argv.length < 3) { | |
console.log('No git path passed as argument, defaulting to ./.git'); | |
} else { | |
path = process.argv[2]; | |
if (process.argv.length < 4) { | |
console.log('No repo branchName passed as argument, defaulting to master'); | |
} else { | |
branchName = process.argv[3]; | |
} | |
} | |
git.Repo.open(path, function(error, repo) { | |
if (error) throw error; | |
repo.getBranch(branchName, function(error, branch) { | |
if (error) throw error; | |
var history = branch.history(); | |
history.on('commit', function(commit) { | |
if (reCurse.test(commit.message())) | |
console.log('Curse detected in commit', commit.sha(), 'message', commit.message()); | |
}).start(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment