FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sourcegraph/dev/forbidcommit.sh at main · linuxfreak/sourcegraph · GitHub
linuxfreak
/
sourcegraph
Public
forked from
sourcegraph/sourcegraph-public-snapshot
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
7
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sourcegraph
/
dev
/
forbidcommit.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
32 lines (27 loc) · 999 Bytes
Breadcrumbs
sourcegraph
/
dev
/
forbidcommit.sh
Copy path
File metadata and controls
executable file
·
32 lines (27 loc) · 999 Bytes
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
#!
/usr/bin/env bash
set
-eu
#
Select the files to inspect. We don't want to list files which are deleted, as it makes no sense
#
to look for a token being committed in those.
#
#
We use --diff-filter, that tells git to only include in the diff files that were:
#
- "A" added
#
- "C" copied
#
- "M" modified
#
- "R" renamed
files=
$(
git diff --name-only --staged --diff-filter ACMR
)
function
check()
{
local
file=
"
$1
"
if
[[
"
$file
"
==
"
dev/forbidcommit.sh
"
||
"
$file
"
==
"
.pre-commit-config.yaml
"
]]
;
then
exit
0
fi
#
-i means case-insensitive
#
-F means searsch for a fixed string, i.e. no pattern matching.
if
grep -iF
'
FORBIDCOMMIT
'
"
$file
"
;
then
echo
"
🔴 Found a FORBIDCOMMIT string in git staged file:
$file
.
"
echo
"
You most likely added this yourself to prevent yourself from accidentally committing that file.
"
echo
"
Please look at your changes carefully before removing the FORBIDCOMMIT pragma.
"
exit
1
fi
}
export
-f check
parallel check :::
"
$files
"
Back
|
FazBrowse Home
|
New Git URL