forked from timvideos/gst-switch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
# | ||
# An example hook script to 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. | ||
# | ||
|
||
function find-indent () { | ||
if [[ -d .git && -h scripts/indent ]]; then | ||
echo $PWD/scripts/indent | ||
else | ||
cd .. && { | ||
find-indent | ||
cd - > /dev/null | ||
} | ||
fi | ||
} | ||
|
||
# If there are whitespace errors, print the offending file names and | ||
files=$(git diff-index --cached --name-only HEAD --diff-filter=ACMR | grep "\.c$") | ||
indent=$(find-indent) | ||
|
||
for file in $files; do | ||
nf=`git checkout-index --temp ${file} | cut -f 1` | ||
newfile=`mktemp /tmp/${nf}.XXXXXX` || exit 1 | ||
$indent $nf -o $newfile 2>> /dev/null | ||
# FIXME: Call indent twice as it tends to do line-breaks | ||
# different for every second call. | ||
$indent $newfile 2>> /dev/null | ||
diff -u -p "${nf}" "${newfile}" | ||
r=$? | ||
rm "${newfile}" | ||
rm "${nf}" | ||
if [ $r != 0 ] ; then | ||
echo "=================================================================================================" | ||
echo " Code style error in: $file " | ||
echo " " | ||
echo " Please fix before committing. Don't forget to run git add before trying to commit again. " | ||
echo " If the whole file is to be committed, this should work (run from the top-level directory): " | ||
echo " " | ||
echo " $indent $file; git add $file; git commit " | ||
echo " " | ||
echo "=================================================================================================" | ||
exit 1 | ||
fi | ||
echo "Code style okay: $file" | ||
done | ||
|
||
echo "Code style okay!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,6 @@ | ||
#!/bin/bash | ||
# | ||
# An example hook script to 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. | ||
# | ||
|
||
function find-indent () { | ||
if [[ -d .git && -h scripts/indent ]]; then | ||
echo $PWD/scripts/indent | ||
else | ||
cd .. && { | ||
find-indent | ||
cd - > /dev/null | ||
} | ||
fi | ||
} | ||
|
||
# If there are whitespace errors, print the offending file names and | ||
files=$(git diff-index --cached --name-only HEAD --diff-filter=ACMR | grep "\.c$") | ||
indent=$(find-indent) | ||
|
||
for file in $files; do | ||
nf=`git checkout-index --temp ${file} | cut -f 1` | ||
newfile=`mktemp /tmp/${nf}.XXXXXX` || exit 1 | ||
$indent $nf -o $newfile 2>> /dev/null | ||
# FIXME: Call indent twice as it tends to do line-breaks | ||
# different for every second call. | ||
$indent $newfile 2>> /dev/null | ||
diff -u -p "${nf}" "${newfile}" | ||
r=$? | ||
rm "${newfile}" | ||
rm "${nf}" | ||
if [ $r != 0 ] ; then | ||
echo "=================================================================================================" | ||
echo " Code style error in: $file " | ||
echo " " | ||
echo " Please fix before committing. Don't forget to run git add before trying to commit again. " | ||
echo " If the whole file is to be committed, this should work (run from the top-level directory): " | ||
echo " " | ||
echo " $indent $file; git add $file; git commit " | ||
echo " " | ||
echo "=================================================================================================" | ||
exit 1 | ||
fi | ||
echo "Code style okay: $file" | ||
done | ||
|
||
echo "Code style okay!" | ||
chmod +x scripts/hooks/c-pre-commit | ||
chmod +x scripts/hooks/py-pre-commit | ||
./scripts/hooks/c-pre-commit | ||
./scripts/hooks/py-pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/hyades/Github/gst-switch/python-api/scripts/hooks/pre-commit |