Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
66 lines (56 loc) · 1.51 KB

File metadata and controls

66 lines (56 loc) · 1.51 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env node
// vim: ft=javascript
// Copyright 2011-2014, Tim Branyen @tbranyen <tim@tabdeveloper.com>
// Dual licensed under the MIT and GPL licenses.
// Script to detect cursewords in commit messages and provide the offending
// commit sha's.
//
// Usage:
//
// node git_profanity_check some/repo/.git
//
var git = require('../../');
var curses = ['put', 'curse', 'words', 'here'];
var path = './.git';
var branch = 'master';
var reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi');
// Default path is `.git`.
if (process.argv.length < 3) {
console.log('No path passed as argument, defaulting to .git.');
}
// Otherwise defaults.
else {
path = process.argv[2];
// Set repo branch
if (process.argv.length < 4) {
console.log('No branch passed as argument, defaulting to master.');
}
else {
branch = process.argv[3];
}
}
// Open repository.
git.Repo.open(path, function(err, repo) {
if (err) {
throw new Error(err);
}
// Open branch, default to master.
repo.getBranch(branch, function(err, branch) {
if (err) {
throw new Error(err);
}
// Iterate history
var history = branch.history();
// Iterate over every commit message and test for words.
history.on('commit', function(commit) {
var message = commit.message();
if (reCurse.test(message)) {
console.log('Curse detected in commit', commit.sha());
console.log('=> ', message);
return;
}
});
// Start history iteration.
history.start();
});
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.