need some help
I was trying to enhance the pre-commit hook to see if I can ignore parsing the commit message if there is a certain key ("!ignore") in the commit message
The if conditions before this one , like to check if there are empty commit messages works. But this if condition somehow is not working.
Ok when I do a commit with message "SMARTCOMMITTEST" which does not contain my check key "!ignore", the commit succeeds which means the If condition below never executed or did not execute as expected. So trying to understand what is wrong wit it.
SMARTCOMMIT=1
$SVNLOOK log -t "$TXN" "$REPOS" | grep "!ignore" | wc -c || SMARTCOMMIT=0
if [ $SMARTCOMMIT = 0];
then
echo "Please use !ignore if you dont want to use smart commits in your commit message." 1>&2
exit 1
fi
Thanks a lot to Etan for some tips...
I changed the condition like the other if condition in the comments and then it worked
SMARTCOMMIT=$($SVNLOOK log -t "$TXN" "$REPOS" | grep "!ignore" | wc -c)
if [ "$SMARTCOMMIT" = "0" ]; then
echo "Please use !ignore if you dont want to use smart commits in your commit message." 1>&2
exit 1
fi
This one worked fine..
@David W .. I now have a situation to check multiple conditions in the same if
SMARTCOMMIT=$($SVNLOOK log -t "$TXN" "$REPOS" | grep '!ignore' | wc -c)
COMMITMESSAGENOREVIEW=$($SVNLOOK log -t "$TXN" "$REPOS" | grep '#comment' | wc -c)
COMMITMESSAGEWITHREVIEW=$($SVNLOOK log -t "$TXN" "$REPOS" | grep '+review' | wc -c)
if [ "$SMARTCOMMIT" = "0" -a "$COMMITMESSAGENOREVIEW" = "0" -a "COMMITMESSAGEWITHREVIEW" = "0" ]; then
echo "Please use #comment or +review to enable smart commits or !ignore to not use smart commits." 1>&2
exit 1
fi
I tried as given in the link here but still I dont see the if condition getting executed at all. Can you help me with this now?