sqlmap/extra/shutils/precommit-hook.sh

42 lines
1.3 KiB
Bash
Raw Normal View History

2016-02-29 02:20:58 +03:00
#!/bin/bash
2018-12-10 15:21:36 +03:00
: '
2018-12-10 15:20:34 +03:00
cat > .git/hooks/pre-commit << EOF
#!/bin/bash
source ./extra/shutils/precommit-hook.sh
EOF
chmod +x .git/hooks/pre-commit
2018-12-10 15:21:36 +03:00
'
2018-12-10 15:20:34 +03:00
2016-07-17 00:25:13 +03:00
PROJECT="../../"
2016-02-29 02:20:58 +03:00
SETTINGS="../../lib/core/settings.py"
DIGEST="../../sha256sums.txt"
2016-02-29 02:20:58 +03:00
declare -x SCRIPTPATH="${0}"
2016-07-17 00:25:13 +03:00
PROJECT_FULLPATH=${SCRIPTPATH%/*}/$PROJECT
SETTINGS_FULLPATH=${SCRIPTPATH%/*}/$SETTINGS
DIGEST_FULLPATH=${SCRIPTPATH%/*}/$DIGEST
2016-02-29 02:20:58 +03:00
2017-01-02 16:19:18 +03:00
git diff $SETTINGS_FULLPATH | grep "VERSION =" > /dev/null && exit 0
2018-01-02 03:08:47 +03:00
if [ -f $SETTINGS_FULLPATH ]
then
LINE=$(grep -o ${SETTINGS_FULLPATH} -e 'VERSION = "[0-9.]*"')
declare -a LINE
2019-01-06 02:29:31 +03:00
INCREMENTED=$(python -c "import re, sys, time; version = re.search('\"([0-9.]*)\"', sys.argv[1]).group(1); _ = version.split('.'); _.extend([0] * (4 - len(_))); _[-1] = str(int(_[-1]) + 1); month = str(time.gmtime().tm_mon); _[-1] = '0' if _[-2] != month else _[-1]; _[-2] = month; print sys.argv[1].replace(version, '.'.join(_))" "$LINE")
2018-01-02 03:08:47 +03:00
if [ -n "$INCREMENTED" ]
then
sed -i "s/${LINE}/${INCREMENTED}/" $SETTINGS_FULLPATH
echo "Updated ${INCREMENTED} in ${SETTINGS_FULLPATH}"
else
echo "Something went wrong in VERSION increment"
exit 1
fi
git add "$SETTINGS_FULLPATH"
fi
cd $PROJECT_FULLPATH && git ls-files | sort | uniq | grep -v sha256 | xargs sha256sum > $DIGEST_FULLPATH