FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/example/apps/git_profanity_check.js at v0.0.72 · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
21
(21)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
example
/
apps
/
git_profanity_check.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
54 lines (46 loc) · 1.28 KB
Breadcrumbs
nodegit
/
example
/
apps
/
git_profanity_check.js
Copy path
File metadata and controls
54 lines (46 loc) · 1.28 KB
Raw
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
#!/usr/bin/env node
// Copyright 2011, 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.
// vim: ft=javascript
var
git
=
require
(
'nodegit'
)
;
var
curses
=
[
'add'
,
'swears'
,
'here'
]
,
path
=
'./.git'
,
branch
=
'master'
,
reCurse
=
new
RegExp
(
'\\b(?:'
+
curses
.
join
(
'|'
)
+
')\\b'
,
'gi'
)
;
// Set git path
if
(
process
.
argv
.
length
<
3
)
{
console
.
log
(
'No path passed as argument, defaulting to ./.git'
)
;
}
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
(
path
,
function
(
err
,
repo
)
{
if
(
err
)
{
throw
new
Error
(
err
)
;
}
// Open branch
repo
.
branch
(
branch
,
function
(
err
,
branch
)
{
if
(
err
)
{
throw
new
Error
(
err
)
;
}
// Iterate history
var
history
=
branch
.
history
(
)
;
history
.
on
(
'commit'
,
function
(
idx
,
commit
)
{
// Check commit messages first
if
(
reCurse
.
test
(
commit
.
message
)
)
{
console
.
log
(
'Curse detected in commit'
,
commit
.
sha
,
'message'
)
;
return
;
}
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL