svn server mandatory annotation configuration method

[size=xx-small] This requirement can be easily achieved by using the pre-commit hook of svn: [/size]

    Enter the hooks directory of the warehouse (eg: project1/hooks), find the pre-commit.tmpl file, and rename it: windows Modify it to pre-commit.bat in the environment, and modify it to pre-commit in the Linux environment.

Windows environment: (tested)

    Open the pre-commit.bat file with Notepad, and edit the following script (it will take effect after saving, no need to restart the service)

    The prompt information can be modified
@echo off
 setlocal
 set REPOS=%1
 set TXN=%2          
 
rem guarantees input of 8 characters
 svnlook log %REPOS% -t %TXN% | findstr "........" > nul
 if %errorlevel% gtr 0 goto :err_action
 
rem filter whitespace characters
svnlook log %REPOS% -t %TXN% | findstr /ic:"        " > nul
 if %errorlevel% gtr 0 goto :success
 
 :err_action
 echo You submitted this version without filling in the log description information of any changes. >&2
 echo Please add the log description information before submitting the code, such as: function description, etc. >&2
 The log information entered by echo is not less than 8 characters (or 4 Chinese characters), thank you! >&2
 echo ********************Forbid space data**************** >&2

 goto :err_exit
  :err_exit
 exit 1
 
 :success
 exit 0


In Linux environment (not tested)

    , edit the file pre-commit with editing commands such as Vi. The editing content is as follows (you need to add executable permission to the file after editing: chmod +x pre-commit )

    The prompt information can be modified
#!/bin/sh
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook

# check that logmessage contains at least 10 alphanumeric characters
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 10 ]; #Required that the comment should not be less than 5 characters, it can be customized, and the prompt information can also be customized
then
echo -e "\nEmpty log message not allowed. Commit aborted!" 1>&2
exit 1
be

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326870867&siteId=291194637