subversion-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amitakhya Phukan <aphu...@fedoraproject.org>
Subject Help with svn pre-commit hook needed
Date Tue, 10 Jan 2012 15:11:30 GMT
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@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

Mime
View raw message