Http://jdev.tw/blog/340/subversion-hook-scripts
The subversion can be controlled after the commit is committed. For example:
- Pre-commit (pre-commit) checks the permission limit on its own, and only the collaborators can commit the committed commit.
- Post-commit (post-commit) automatically sends mail to the specified person
- After the commit, the system will initiate a manual import to facilitate future query.
Subversion provides the following types of events that can be handled on your own.Hook scripts(Required) It must be optional. In Windows, it is recommended that the example Board be stored in subversion.Hooks information of the case studyHere:
order |
event |
function description |
example Board |
1 |
Pre-commit |
Committed row before commit |
Pre-commit.tmpl |
2 |
Pre-Lock |
The transaction is committed before the transaction is finalized. |
Pre-lock.tmpl |
3 |
Pre-revprop-change |
The statement is added, modified, or deleted before it is deleted. |
Pre-revprop-change.tmpl |
4 |
Pre-Unlock |
Confirmed before case dissolution |
Pre-unlock.tmpl |
5 |
Post-commit |
Merged rows after commit |
Post-commit.tmpl |
6 |
Post-Lock |
The statement will be canceled after it is finalized. |
Post-lock.tmpl |
7 |
Post-revprop-change |
The statement is added, modified, or deleted. |
Post-revprop-change.tmpl |
8 |
Post-Unlock |
Executed after the case is canceled |
Post-unlock.tmpl |
9 |
Start-commit |
The row is deleted before the start of the operation. |
Start-commit.tmpl |
The processing concepts here are similar to those in CVS. (You can refer to my previous article:Loginfo. RB: Send a change email automatically), But it is troublesome that the Subversion only generates the revision sequence of the active and active records, other information, such as the author, mobile time, mobile case, and mobile content, cannot be directly exported to the hook scripts; after reading some files and routines, I found that these resources must be passed through.Svn-win32-1.2.3binsvnlook.exeIn order to get, I made a simple example, the name is the case of the project category/hooks/post-commit.bat:
Command |
Description |
Set apr_iconv_path = D: svn-win32-1.2.3iconv |
Set hosts to locale |
Echo % 1% 2> D: repohookspost.txt |
After reading the post-commit command, I sent the things to the hook script. |
Echo-changed:> D: repohookspost.txt D: svn-win32-1.2.3binSVNLOOK changed "% 1" "% 2"> D: repohookspost.txt |
Add the registrant domains to post.txt |
Echo-Date:> D: repohookspost.txt D: svn-win32-1.2.3binSVNLOOK date "% 1" "% 2"> D: repohookspost.txt |
Import the specified parameter into post.txt |
Echo-log :>> D: repohookspost.txt D: svn-win32-1.2.3binSVNLOOK log "% 1" "% 2"> D: repohookspost.txt |
Add the logstores added by commitaskforpost.txt |
Echo-Author:> D: repohookspost.txt D: svn-win32-1.2.3binSVNLOOK Author "% 1" "% 2"> D: repohookspost.txt |
Upload the author to post.txt |
Echo-youngest:> D: repohookspost.txt D: svn-win32-1.2.3binSVNLOOK youngest "% 1" "% 2"> D: repohookspost.txt |
Overwrite the latest sequence into post.txt |
Echo-DIFF:> D: repohookspost.txt D: svn-win32-1.2.3binSVNLOOK diff "% 1" "% 2"> D: repohookspost.txt |
Include the difference into post.txt |
You can just upload post.txt in another procedure. However, the suffix name of post.txt must be added with the distinguished sequence to prevent many people from using commit at the same time.
##