Starting to use Uniglot for hooks standardization.
This commit is contained in:
30
Hooks/scripts.d/nonascii
Executable file
30
Hooks/scripts.d/nonascii
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Sourced from https://github.com/git/git/blob/master/templates/hooks--pre-commit.sample
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --bool hooks.allownonascii)
|
||||
|
||||
# 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
|
8
Hooks/scripts.d/pytest
Executable file
8
Hooks/scripts.d/pytest
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run python3 tests
|
||||
|
||||
if [ -d venv ]; then
|
||||
source venv/bin/activate
|
||||
fi
|
||||
python3 -m pytest
|
20
Hooks/scripts.d/stop-foxtrots
Executable file
20
Hooks/scripts.d/stop-foxtrots
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Borrowing from https://github.com/syncier/pre-commit-hooks-jumanjihouse/blob/master/pre_commit_hooks/protect-first-parent
|
||||
|
||||
# Find the correct reference, or fallback to HEAD's abbrev-ref
|
||||
base="$(
|
||||
git rev-parse --abbrev-ref --symbolic-full-name '@{upstream}' 2>/dev/null \
|
||||
|| git branch -avv | awk '/->/ {print $NF}' 2>/dev/null \
|
||||
|| :
|
||||
)"
|
||||
if [ -z "$base" ]; then base="$(git rev-parse --abbrev-ref HEAD)"; fi
|
||||
|
||||
firstParent="$(git show-ref -s "${base}")"
|
||||
|
||||
if git rev-list --first-parent "${base}^".. | grep -q "^${firstParent}$"; then
|
||||
exit 0
|
||||
else
|
||||
echo Foxtrot detected -- please either rebase or '`git reset --soft`' to recreate your commit.
|
||||
exit 1
|
||||
fi
|
23
Hooks/scripts.d/whitespace
Executable file
23
Hooks/scripts.d/whitespace
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Sourced from https://github.com/git/git/blob/master/templates/hooks--pre-commit.sample
|
||||
|
||||
if egrep -irl '\s\+$' .; then
|
||||
echo The above lines have trailing whitespace. Run "sed -i 's/\s\+$//'" on the affected files.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
Reference in New Issue
Block a user