Skip to content

Commit

Permalink
mainly pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sorgom committed Oct 16, 2024
1 parent d7d4cbe commit 9b09d19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 12 additions & 5 deletions .gitHooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
#!/usr/bin/bash
# use: git config core.hooksPath .gitHooks

# availabilty of python
py=$(which py || which python || which python3)
if [[ -z $py ]]
then
echo "No python found"
exit 0
fi

# go to the root of the git repo
cd $(git rev-parse --show-toplevel)

# path to sompy python scripts
sompy=$(pwd)/sompy/somutil

mdjs=
svgs=
# files regarded as text files to be cleaned
txts=
# extensions of text files sorted by likeliness
xtxt="h cpp cmd py md"

for file in `git diff-index --cached --name-only HEAD`;
do
for file in `git diff-index --cached --name-only HEAD`; do
if [[ -f $file ]]
then
if [[ $file == *.mdj ]]; then mdjs="$mdjs $file"
elif [[ $file == *.svg ]]; then svgs="$svgs $file"
elif [[ $file == *.py ]] || [[ $file == *.cpp ]] || [[ $file == *.h ]] || [[ $file == *.cmd ]] || [[ $file == *.md ]]
then
txts="$txts $file"
else
for ext in $xtxt; do
if [[ $file == *.$ext ]]; then txts="$txts $file"; break; fi
done
fi
fi
done
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ __pycache__
tmp.*
tmp_*
old_*
tmp

# vscode
tempCodeRunnerFile.py
Expand Down

0 comments on commit 9b09d19

Please sign in to comment.