Skip to content

Commit

Permalink
Mac compatibility for prepare-commit.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 2, 2017
1 parent cd559ea commit 6681766
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions scripts/prepare-commit.sh
Expand Up @@ -20,6 +20,12 @@ PATH=$TOPLEVEL/scripts:$PATH

cd $TOPLEVEL

# GNU prefix command for mac os support (gsed, gsplit)
GP=
if [[ "$OSTYPE" =~ darwin* ]]; then
GP=g
fi

if ! type -p astyle.sh >/dev/null; then
echo astyle.sh not found
exit 1
Expand All @@ -40,7 +46,7 @@ fi
set -e

# determine changed files
MODIFIED=$(git status --porcelain| sed -ne "s/^ *[MA] *//p" | sort -u)
MODIFIED=$(git status --porcelain| ${GP}sed -ne "s/^ *[MA] *//p" | sort -u)

if [ -z "$MODIFIED" ]; then
echo nothing was modified
Expand Down Expand Up @@ -108,11 +114,11 @@ for f in $MODIFIED; do
if [[ $f =~ ^src\/(core|gui|analysis)\/.*\.h$ ]]; then
# look if corresponding SIP file
#echo $f
sip_include=$(sed -r 's/^src\/(\w+)\/.*$/python\/\1\/\1.sip/' <<< $f )
sip_file=$(sed -r 's/^src\/(core|gui|analysis)\///; s/\.h$/.sip/' <<<$f )
sip_include=$(${GP}sed -r 's/^src\/(\w+)\/.*$/python\/\1\/\1.sip/' <<< $f )
sip_file=$(${GP}sed -r 's/^src\/(core|gui|analysis)\///; s/\.h$/.sip/' <<<$f )
if grep -Exq "^\s*%Include $sip_file" ${TOPLEVEL}/$sip_include ; then
#echo "in SIP"
sip_file=$(sed -r 's/^src\///; s/\.h$/.sip/' <<<$f )
sip_file=$(${GP}sed -r 's/^src\///; s/\.h$/.sip/' <<<$f )
# check it is not blacklisted (i.e. manualy SIP)
if ! grep -Fxq "$sip_file" python/auto_sip.blacklist; then
#echo "automatic file"
Expand Down

0 comments on commit 6681766

Please sign in to comment.