Initial commit

This commit is contained in:
Sonny 2019-05-19 14:18:51 +00:00
commit fa9f56a5ed
7 changed files with 102 additions and 0 deletions

13
post-commit Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
# Check if the directory is the root directory
if [ ! -d ".git/" ]; then
echo "Please commit from within the root directory"
exit 1
fi
# Run every file inside the post-commit.d directory
for file in .git/hooks/post-commit.d/*
do
. $file
done

20
post-commit.d/ctags.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/bash
TAG_DIR="$HOME/.tags"
PROJECT_TAG_FILE="omx-gui.tags"
if [ "$CREATE_TAGS" != true ]; then
exit 0
fi
if [ ! -x /usr/bin/ctags ]; then
echo "ctags binary is not executable or not present!"
exit 1
fi
if [ ! -d $HOME/.tags ]; then
echo "tags directory not created, creating it for you.."
/bin/mkdir $HOME/.tags
fi
/usr/bin/ctags -f "$TAG_DIR/$PROJECT_TAG_FILE" -R --languages=Python,Javascript > /dev/null 2>&1

13
pre-commit Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
# Check if the directory is the root directory
if [ ! -d ".git/" ]; then
echo "Please commit from within the root directory"
exit 1
fi
# Run every file inside the pre-commit.d directory
for file in .git/hooks/pre-commit.d/*
do
. $file
done

14
pre-commit.d/autoflake.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
FILES=$(git diff --cached --name-only --diff-filter=ACM "*.py" | sed 's| |\\ |g')
if [ ! -z "$FILES" ]; then
# Format all selected files
echo "$FILES" | xargs -I {} /bin/bash -c "/home/sonny/.local/bin/autoflake --in-place --remove-unused-variables {}"
if [ $? -ne 0 ]; then
exit 1
fi
# Add back the modified files to staging
echo "$FILES" | xargs git add
fi

14
pre-commit.d/isort.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
FILES=$(git diff --cached --name-only --diff-filter=ACM "*.py" | sed 's| |\\ |g')
if [ ! -z "$FILES" ]; then
# Format all selected files
echo "$FILES" | xargs ./env/bin/isort
if [ $? -ne 0 ]; then
exit 1
fi
# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add
fi

14
pre-commit.d/prettier.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
FILES=$(git diff --cached --name-only --diff-filter=ACM "*.js" | sed 's| |\\ |g')
if [ ! -z "$FILES" ]; then
# Prettify all selected files
echo "$FILES" | xargs ./node_modules/.bin/prettier --write
if [ $? -ne 0 ]; then
exit 1
fi
# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add
fi

14
pre-commit.d/yapf.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
FILES=$(git diff --cached --name-only --diff-filter=ACM "*.py" | sed 's| |\\ |g')
if [ ! -z "$FILES" ]; then
# Format all selected files
echo "$FILES" | xargs ./env/bin/yapf --in-place --verbose --style=./yapf.conf
if [ $? -ne 0 ]; then
exit 1
fi
# Add back the modified files to staging
echo "$FILES" | xargs git add
fi