SVN pre-commit issue

[亡魂溺海] 提交于 2019-12-06 04:11:59

This means it isn't even executing your hook. Whenever you get an error like that, it can mean several things:

  • The shebang at the top of your script is incorrect. Maybe on your system, there's no BASH shell or that the BASH shell is located at /usr/local/bin/bash or /usr/share/bin/bash. Unlikely on a Linux system, but very likely on Solaris. Check this.
  • The script doesn't have the executable bit set. You need to do a chmod +x on your script.
  • The pre-commit shell script isn't able to call your script itself. Take a look at the pre-commit script inside the hook directory and make sure it's calling your script. Or, that you've renamed your script to pre-commit and put it in that directory.

Another possibility (looking more closely at your script) is that you've confused the pre-commit BASH script with the pre-commit.bat version for Windows shell. Your syntax is Windows shell in the second half of your script, but your top half is BASH shell.

Here's my pre-commit hook. It's in Perl, so it works with both Windows and Unix/Linux/Mac. You'll have to install ActivePerl or Strawberry Perl on your Windows box, but both are free and open source.

My pre-commit script can do several things such as make sure people don't accidentally change tags by allowing people to create tags, but not modify them.

My script also allows a bit more checking with the commit comment. For example, do you use a bug tracking system? You can set up my hook to require a bug tracking ID in the commit comment.

Another possibility (and something I'd really recommend) is to use a continuous build tool like Jenkins. Jenkins automatically does a build and will run tests with each commit. This makes sure that errors are caught early rather than say post-production.

The big advantage of Jenkins is that it presents a beautiful webpage with all sorts of information like who made the changes and what changes they made. Developers find this so helpful that they automatically start putting in good commit comments without being asked. It's amazing that I can go through a Subversion change log and pinpoint the exact moment I've started using Jenkins.

In your pre-commit script, you merely check for empty comments. If your developers don't feel like putting in comments, you'll start getting comments like changed code and adaadsdasdasda just to allow the commit to go through. With something like Jenkins, the developers actually start putting in good commit comments on their own.

Have you checked to see that pre-commit is set to executable.

ls -l pre-commit

Note it must also be executable by the process that serves your svn repo, in my case httpd.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!