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.