Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hooks/check-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re, sys

PAT_TAB = re.compile("#?\t*[^\t]*$")
PAT_BAD_COMMENT = re.compile(r"\s*//")

def checkascii(l):
return any((ord(c) < 32 or ord(c) > 127) and c != '\t' for c in l)
Expand Down Expand Up @@ -45,6 +46,9 @@ def checkascii(l):
if is_source and l.startswith(" "):
sys.stderr.write("*** {}:{}: Use tabs for indentation: '{}'\n".format(filename, line, l))
status = 1
if is_source and PAT_BAD_COMMENT.match(l):
sys.stderr.write("*** {}:{}: Use /* */ for free standing comments: '{}'\n".format(filename, line, l))
status = 1
line += 1
elif l.startswith(" "):
line += 1
Expand Down
7 changes: 7 additions & 0 deletions test/cases/case8.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Foo
// bar

int foo()
{
return bar;
}
7 changes: 7 additions & 0 deletions test/cases/case9.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Foo
// bar

int foo()
{
return bar;
}
8 changes: 8 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ git_good add case7.cpp
test_commit_bad "Add: Preprocessor hash indented"
git_good reset case7.cpp

git_good add case8.cpp
test_commit_bad "Add: Wrong comment style"
git_good reset case8.cpp

git_good add case9.cpp
test_commit_bad "Add: Wrong comment style"
git_good reset case9.cpp

git_good push

# setup badguy
Expand Down