git: add .githooks to repository
- Add git pre-commit and pre-push hooks - To enable type 'git config core.hooksPath .githooks' - For for additional example hooks see the .git/hooks directory Change-Id: I92155f4083c8547759bfbbfe4df64923548fa4d5 Signed-off-by: Ed Rodriguez <ed.rodriguez@netapp.com> Signed-off-by: John Meneghini <johnm@netapp.com> Reviewed-on: https://review.gerrithub.io/409577 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
7af03370b0
commit
22898a91b9
28
.githooks/pre-commit
Executable file
28
.githooks/pre-commit
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# 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.
|
||||
|
||||
rc=0
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# If there are formatting errors, print the offending file names and fail.
|
||||
if [ -x "./scripts/check_format.sh" ]; then
|
||||
echo "Running check_format.sh ..."
|
||||
"./scripts/check_format.sh" > check_format.log 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
cat check_format.log
|
||||
echo ""
|
||||
echo "ERROR check_format.sh returned errors!"
|
||||
echo "ERROR Fix the problem and use 'git add' to update your changes."
|
||||
echo "ERROR See `pwd`/check_format.log for more information."
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
exit $rc
|
126
.githooks/pre-push
Executable file
126
.githooks/pre-push
Executable file
@ -0,0 +1,126 @@
|
||||
#!/bin/sh
|
||||
# Verify what is about to be pushed. Called by "git
|
||||
# push" after it has checked the remote status, but before anything has been
|
||||
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||
#
|
||||
# This hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- Name of the remote to which the push is being done
|
||||
# $2 -- URL to which the push is being done
|
||||
#
|
||||
# If pushing without using a named remote those arguments will be equal.
|
||||
|
||||
# <local ref> <local sha1> <remote ref> <remote sha1>
|
||||
#
|
||||
|
||||
rc=0
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
|
||||
MAKE="make -j ${nproc}"
|
||||
|
||||
echo "Running make with gcc ..."
|
||||
echo "make clean " > make.log
|
||||
$MAKE clean >> make.log 2>&1
|
||||
echo "make CONFIG_DEBUG=n CONFIG_WERROR=y " >> make.log
|
||||
$MAKE CONFIG_DEBUG=n CONFIG_WERROR=y >> make.log 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
tail -20 make.log
|
||||
echo ""
|
||||
echo "ERROR make returned errors!"
|
||||
echo "ERROR Fix the problem and use 'git commit' to update your changes."
|
||||
echo "ERROR See `pwd`/make.log for more information."
|
||||
echo ""
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
echo "make clean " >> make.log
|
||||
$MAKE clean >> make.log 2>&1
|
||||
echo "make CONFIG_DEBUG=y CONFIG_WERROR=y " >> make.log
|
||||
$MAKE CONFIG_DEBUG=y CONFIG_WERROR=y >> make.log 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
tail -20 make.log
|
||||
echo ""
|
||||
echo "ERROR make returned errors!"
|
||||
echo "ERROR Fix the problem and use 'git commit' to update your changes."
|
||||
echo "ERROR See `pwd`/make.log for more information."
|
||||
echo ""
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
echo "Running unittest.sh ..."
|
||||
echo "./test/unit/unittest.sh" >> make.log
|
||||
"./test/unit/unittest.sh" >> make.log 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
tail -20 make.log
|
||||
echo ""
|
||||
echo "ERROR unittest returned errors!"
|
||||
echo "ERROR Fix the problem and use 'git commit' to update your changes."
|
||||
echo "ERROR See `pwd`/make.log for more information."
|
||||
echo ""
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
echo "make clean " >> make.log
|
||||
$MAKE clean >> make.log 2>&1
|
||||
|
||||
if ! hash clang 2>/dev/null; then
|
||||
echo "clang not found; skipping the clang tests"
|
||||
echo
|
||||
echo "Pushing to $1 $2"
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
echo "Running make with clang ..."
|
||||
echo "make CONFIG_DEBUG=n CONFIG_WERROR=y CC=clang CXX=clang++ " >> make.log
|
||||
$MAKE CONFIG_DEBUG=n CONFIG_WERROR=y CC=clang CXX=clang++ >> make.log 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
tail -20 make.log
|
||||
echo ""
|
||||
echo "ERROR make CC=clang CXX=clang++ returned errors!"
|
||||
echo "ERROR Fix the problem and use 'git commit' to update your changes."
|
||||
echo "ERROR See `pwd`/make.log for more information."
|
||||
echo ""
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
echo "make clean CC=clang CXX=clang++ " >> make.log
|
||||
$MAKE clean CC=clang CXX=clang++ >> make.log 2>&1
|
||||
echo "make CONFIG_DEBUG=y CONFIG_WERROR=y CC=clang CXX=clang++ " >> make.log
|
||||
$MAKE CONFIG_DEBUG=y CONFIG_WERROR=y CC=clang CXX=clang++ >> make.log 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
tail -20 make.log
|
||||
echo ""
|
||||
echo "ERROR make CC=clang CXX=clang++ returned errors!"
|
||||
echo "ERROR Fix the problem and use 'git commit' to update your changes."
|
||||
echo "ERROR See `pwd`/make.log for more information."
|
||||
echo ""
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
echo "Running unittest.sh ..."
|
||||
echo "./test/unit/unittest.sh" >> make.log
|
||||
"./test/unit/unittest.sh" >> make.log 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
tail -20 make.log
|
||||
echo ""
|
||||
echo "ERROR unittest returned errors!"
|
||||
echo "ERROR Fix the problem and use 'git commit' to update your changes."
|
||||
echo "ERROR See `pwd`/make.log for more information."
|
||||
echo ""
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
$MAKE clean CC=clang CXX=clang++ 2> /dev/null
|
||||
|
||||
echo "Pushing to $1 $2"
|
||||
|
||||
exit $rc
|
11
CHANGELOG.md
11
CHANGELOG.md
@ -2,6 +2,17 @@
|
||||
|
||||
## v18.07: (Upcoming Release)
|
||||
|
||||
### git pre-commit and pre-push hooks
|
||||
|
||||
The pre-commit hook will run `scripts/check_format.sh` and verify there are no formating
|
||||
errors before allowing `git commit` to run. The pre-push hook runs `make CONFIG_WERROR=y`
|
||||
with and without `CONFIG_DEBUG=y` using both the gcc and clang compiler before allowing
|
||||
`git push` to run. Following each DEBUG build `test/unit/unittest.sh` is run and verified.
|
||||
Results are recorded in the `make.log` file.
|
||||
|
||||
To enable type: 'git config core.hooksPath .githooks'. To override after configuration use
|
||||
the `git --no-verify` flag.
|
||||
|
||||
## v18.04: Logical Volume Snapshot/Clone, iSCSI Initiator, Bdev QoS, VPP Userspace TCP/IP
|
||||
|
||||
### vhost
|
||||
|
Loading…
x
Reference in New Issue
Block a user