SVN forces the submission of comments-Pre-commit hooks

Source: Internet
Author: User
Many developers do not write comments when submitting changes, which makes it difficult to view the history and does not conform to the specifications. Some companies require that the bug number or task description be written every time they submit changes. How can developers avoid comments on tools?

The pre-commit hook of SVN can be used to easily implement this requirement.

Go to the repository project1/hooks directory, find the pre-commit.tmpl file, rename, remove the suffix. tmpl.
Edit the pre-commit file:

Set:
$ Svnlook log-T "$ txn" "$ repos" | \
Grep "[a-zA-Z0-9]">/dev/null | Exit 1
Commit-access-control.pl "$ repos" "$ txn" commit-access-control.cfg | Exit 1
Comment out the three lines (with the # symbol added before ),
Add the following lines at this location:

Logmsg = '$ svnlook log-T "$ txn" "$ repos" | grep "[a-zA-Z0-9]" | WC-C'
If ["$ logmsg"-lt 5]; # The comments must not be less than five characters long. You can customize
Then
Echo-e "\ nlog message cann' t be empty! You must input more than 5 chars as comment !. "1> & 2
Exit 1
Fi

Save and exit.
Add the executable permission to pre-commit:
Chmod + x pre-commit

The configuration is complete and can be used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.