svn pre-commit hook没有被执行

时间:2015-08-03 18:14:07

标签: svn pre-commit-hook

我知道这个问题在这里问过很多次,但我的问题是我尝试了这里列出的每个解决方案,但仍然遇到执行预提交挂钩的问题。

我的svn存储库托管在此路径/ svn / development /中的linux框中 我修改了/svn/development/hooks/pre-commit.sh文件,如下所示

  REPOS="$1"
  TXN="$2"
  SVNLOOK=/usr/bin/svnlook
  SVNLOOKOK=1

 $SVNLOOK log -t "$TXN" "$REPOS" | \
 grep "[a-zA-Z0-9]" > /dev/null || SVNLOOKOK=0
 if [ $SVNLOOKOK -eq 0 ]; then
 echo -e "Empty log messages are not allowed. Make sure you provide a valid JIRA number and a meaningful log message." 1>&2 || exit 1
 fi
 exit 0

尝试从托管我的svn存储库的本地提交本地提交,并远程使用Tortoise svn。我能够提交null消息。

    1) Modified /etc/selinux/config -> SELINUX=disabled to enforcing and restarted apache
    2) Ran chcon -t httpd_exec_t pre-commit  
    3) Verified all the permissions. 

有人能告诉我我错过了什么吗?

2 个答案:

答案 0 :(得分:3)

好的我知道问题是什么,我从未想过会是这样的。我的脚本名为pre -comit.sh,但看起来根本不应该有任何扩展名。我将它重命名为预先提交,它工作得很好。我尝试的选项1和2也是强制性的,脚本也可以使用。我的新脚本检查空消息并在JIRA中检查有效的问题编号,然后是消息。我已经给出了下面的脚本。

参考:SVN hooks not working

另请阅读此处http://svnbook.red-bean.com/en/1.8/svn.reposadmin.create.html#svn.reposadmin.create.hooks

中的实施存储库挂钩
 #!/bin/bash
 REPOS="$1"
 TXN="$2"

 SVNLOOK=/usr/bin/svnlook
 CURL=/usr/bin/curl
 JIRAURL=http://host/rest/api/2/issue
 # Make sure that the log message is not null
 LOGMSG=$($SVNLOOK log -t "$TXN" "$REPOS")
 if [ `echo ${LOGMSG} | grep "[a-zA-Z0-9]" | wc -c` -lt 8 ]
    then
       echo "Provide a meaningful comment when committing changes" >&2
       exit 1
 fi
 # check that log message starts with a JIRA issue number
 JIRAID=$(expr "${LOGMSG}" : '^\([A-Z]*-[0-9]*\)[: ].*')
 if [[ "$JIRAID" == "" ]]
    then
      echo "svn commit message should start with a valid JIRA id followed by a meaningful log message " >&2
      exit 1
 fi

 # check if JIRA issue exists
 JIRAISSUE=$(${CURL} ${JIRAURL}/${JIRAID})
 if [[ "${JIRAISSUE}" =~ "Issue Does Not Exist" ]]
    then
       echo "${JIRAID} is not a valid JIRA number." >&2
       echo "svn commit message should start with a valid JIRA id followed  by a meaningful log message" >&2
       exit 1
  fi

答案 1 :(得分:0)

您正在将您的变量与数字错误地进行比较。你这样做是为了进行字符串比较。见https://superuser.com/q/688882/233630;有几种方法可以正确地完成,包括替换" ="用" -eq"。

相关问题