[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Help with svn pre-commit hook needed

From: Amitakhya Phukan <aphukan_at_fedoraproject.org>
Date: Tue, 10 Jan 2012 20:41:30 +0530

Hi all,

I have a svn structure where we need to enable code collaborator check-in
for a particular branch, branch5.

For this, I have written the following pre-commit hook script.

====================================================
#!/bin/bash

dbUserName="dbuser"
dbPassword="dbuser_at_123"
dbIP="192.168.0.178"
dbSchema="codecollabdb"
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
if [[ `echo "$BRANCH" | grep
"branch1\|branch2\|branch3\|branch4\|branch6\|branch7...\|branch50"`
== "" ]] ; then

 if [[ `echo "$LOGMSG" | grep "review"` != "" ]]; then
   SVNLogMsg=`"$SVNLOOK" log -t "$TXN" "$REPOS"`
   reviewMsg=`echo ${SVNLogMsg#*:}`
   reviewId=`echo ${reviewMsg% *}`
   echo $SVNLogMsg "," $reviewMsg "," $reviewId 1>&1
   query="select review_phaseid from review where review_id='$reviewId';"
   echo "Query is " $query
   reviewPhaseId=`mysql -u $dbUserName --skip-column-names
-p$dbPassword $dbSchema -h $dbIP -e "$query"`
   echo "review Phase Id is " $reviewPhaseId 1>&2
   if [[ $reviewPhaseId > 0 ]]; then
      echo "Review Id exists in DB. Now need to check for review
state. whether review has been completed or not" 1>&2
      phaseQuery="select phase_id from phase where phase_title='Completed';"
      phaseId=`mysql -u $dbUserName --skip-column-names -p$dbPassword
$dbSchema -h $dbIP -e "$phaseQuery"`
      echo "PhaseId is " $phaseId 1>&2
        if [[ $phaseId = $reviewPhaseId ]]; then
          echo "Review has been completed. Hence,allowing user to
proceed for check ins" 1>&2
          echo "Committing changes to svn repository" 1>&2

          export INSTALL4J_NO_DB=true

/usr/local/bin/ccollab --url http://192.168.0.145:8082 --user admin
--password password --scm subversion --svn-repo-path $1 --svn-look-exe
/usr/bin/svnlook admin trigger ensure-reviewed --review-id-regex
"review:\s+(\d+)" $2 || exit 1
      exit 0
          echo "comitted" 1>&2
        else
          echo " Review is not completed yet. You are requested to
complete the review before proceeding for check ins" 1>&2
          exit 1
        fi
    else
     echo "Review Id doesnt exist. You are requested to enter a valid
review Id" 1>&2
     exit 1
   fi
 else
  echo "" 1>&2
  echo "*** Your commit has been blocked." 1>&2
  echo "Please make your commit comment contains review Id" 1>&2
  echo "Process End" 1>&2
  exit 1
 fi
else
echo "this branch doesnot require any checks to proceed for check ins"
fi

====================================================

However, even though I am able to commit to all branches without any review
ID, for branch5 also I am able to commit without a review ID. It is clear
that something is wrong with the script. But I am not able to figure out
what. Please help me to correct it.

----
Best regards,
Amitakhya Phukan
Received on 2012-01-10 16:12:07 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.