mirror of
https://github.com/zebrajr/SamRewritten.git
synced 2025-12-06 12:19:51 +01:00
Added cppcheck in pre-commit hook. see if that works
This commit is contained in:
parent
4eb7e5e35b
commit
8043f0ff56
1
.githooks/cppcheck-exclusions.txt
Normal file
1
.githooks/cppcheck-exclusions.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
*:steam/*
|
||||
59
.githooks/pre-commit
Executable file
59
.githooks/pre-commit
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=$(git hash-object -t tree /dev/null)
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --type=bool hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# https://github.com/danmar/cppcheck/blob/master/tools/git-pre-commit-cppcheck
|
||||
# We should pass only added or modified C/C++ source files to cppcheck.
|
||||
changed_files=$(git diff-index --cached $against | \
|
||||
grep -E '[MA] .*\.(c|cpp|cc|cxx)$' | cut -f 2)
|
||||
|
||||
if [ -n "$changed_files" ]; then
|
||||
cppcheck -DDEBUG_CERR -isteam --suppressions-list=.githooks/cppcheck-exclusions.txt --error-exitcode=1 $changed_files
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
||||
6
Makefile
6
Makefile
|
|
@ -10,14 +10,20 @@ OBJDIR=obj
|
|||
OBJS=$(addprefix ${OBJDIR}/,$(subst .cpp,.o,${CXXFILES}))
|
||||
|
||||
all: CXXFLAGS += -O3
|
||||
all: init
|
||||
all: ${CURDIR}/bin/samrewritten
|
||||
@echo -e "==== Use '\033[1mmake dev\033[0m' to keep debug symbols"
|
||||
@echo -e "==== Use '\033[1mmake clean\033[0m' to remove object files"
|
||||
@echo -e "==== Nothing left to do."
|
||||
|
||||
dev: CXXFLAGS += -g -DDEBUG_CERR
|
||||
dev: init
|
||||
dev: ${CURDIR}/bin/samrewritten
|
||||
|
||||
init:
|
||||
git config core.hooksPath .githooks
|
||||
@echo "Hooks set to .githooks"
|
||||
|
||||
clean:
|
||||
${RMDIR} ${OBJDIR}
|
||||
|
||||
|
|
|
|||
6
TODO
6
TODO
|
|
@ -1,4 +1,2 @@
|
|||
|
||||
-- done? I finished the stat encoding, but did not test. ALso, now do the decoding
|
||||
|
||||
Next task: try printing stats in the client side. I just finished decode_stats.
|
||||
GUI when no stats are available
|
||||
VSCode CPP Intellisense is always broken, find a fix or change editor / linter?
|
||||
Loading…
Reference in New Issue
Block a user