I have a pre-commit hook that fails commit if anyone is trying to commit restricted files. However, i want to provide access to certain people who can commit by bypassing pre-commit hook. Let me know how can i do it. I'm not much expert in scripting.
Pre-Commit hook:
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
LOGMSG=$($SVNLOOK log -t "$TXN" "$REPOS")
# check if any comment has supplied by the commiter
if [ -z "$LOGMSG" ]; then
echo "Your commit was blocked because it have no comments."
exit 1
fi 1>&2
#check minimum size of text
if [ ${#LOGMSG} -lt 15 ]; then
echo "Your Commit was blocked because the comments does not meet minimum length requirements (15 letters)."
exit 1
fi 1>&2
# get TaskID by regex
TaskID=$(expr "$LOGMSG" : '\([#][0-9]\{1,9\}[:][" "]\)[A-Za-z0-9]*')
# Check if task id was found.
if [ -z "$TaskID" ]; then
echo
echo "No Task id found in log message \"$LOGMSG\""
echo
echo "The TaskID must be the first item on the first line of the log message."
echo
echo "Proper TaskID format--> #123- 'Your commit message' "
exit 1
fi 1>&2
#Check that QA should not be present in log message.
if grep -q ' QA\>' <<< "$LOGMSG"; then
echo
echo "Your log message \"$LOGMSG\" must not contain QA in upper case."
echo
exit 1
fi 1>&2
#Check that restricted files should not get commited.
if [ -x ${REPOS}/hooks/restrict_files.sh ]; then
echo
${REPOS}/hooks/restrict_files.sh "${REPOS}" "${TXN}"
fi 1>&2
restrict_files.sh
#!/bin/bash
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
#Check that restricted files should not get commited.
RESFILES=$($SVNLOOK changed -t "$TXN" "$REPOS")
if grep -E '/*/httpdocs/libs/class.logs.php'\|'/*/httpdocs/app/models/login.php'\|'/*/httpdocs/app/controller/login.php'\|'/*/httpdocs/check_session.php'\|'/*/httpdocs/index.php'\|'/*/httpdocs/config/db.php'\|'/*/httpdocs/config/path.php'\|'/*/httpdocs/Salesp/config/constant.php'\|'/*/generic/common/CarrierConstants.php'\|'/*/generic/Carrier/GetVendorCommonFunction.php' <<< "$RESFILES" >/tmp/rest.txt; then
echo
echo "You are trying to commit restricted files:"
rest=$(</tmp/rest.txt)
echo "$rest"
echo
exit 1
fi 1>&2