First, you need to build your own SVN environment, and import and export it successfully, and understand SVN. This is the prerequisite for reading this article ....
Out of the need for the company's development department to synchronously update the server code through SVN, the svn hook (hooks) technology is required. I have never heard of it before, but I can't just Google it. Google once again agreed on the principle: it's a big copy of the world's articles. It's finally done (why? SVN is so powerful that I only do a little). I will not talk much about it. The example above:
Our company's deployment is very simple (SVN and Web services are on the same host ):
Development ----- SVN (storage) ---- online server
Previously (when Hooks is not used ):
The Development Department commit a file. The online service web documents are not synchronized, but must be executed on the svn service.
SVN update command before synchronization.
This is the case now (after Hooks is used ):
The Development Department commit a file to synchronize data online services (web directories) without the svn update command. This reduces the complexity of the process, although this is only a small action, it saves a lot of trouble (especially for web development engineers, you think, code is often changed, and SVN update is always the same thing back and forth, bored, right !)
The Directory of the website to be synchronized is (of course, the assets directory file already exists on the svn server ):
In this way, create an assets directory under the webdir directory (remember to switch to the webdir directory) and run
After running this command, the assets directory on the svn server is checked out under webdir (which contains website files). This is equivalent to making the web directory a Client Directory;
So how can we use hooks to synchronize data? Next
Have you seen the Green file ?! This is actually a shell script:
The dir variable contains the directory to be synchronized. You can use the svn update command and the username and password to synchronize the data. (what I do is that simple, no wonder !), I mainly look at the above figure. There are many objects ending with. tmpl. These are the hooks templates. Do not change the post-commit file name (you need to grant it the execution permission)
After these steps, you do not need to manually execute the post-commit script to complete the requirements required by the Development Department!
Why? Use the Internet (I copied it, sorry !) :
Post-commit
After the submission is complete, run the hook after the version is successfully created. The submission is complete and cannot be changed. Therefore, the return value of this script is ignored.
Post-Lock
Execute the script after the file is locked.
Post-revprop-change
Run the script after modifying the revision attribute. Because the modified draft has been completed and cannot be changed, the return value of this script is ignored (but the actual implementation seems to be that the correct execution of this script affects Attribute Modification)
Post-Unlock
The script is executed after the file is unlocked.
Pre-commit
After subversion transaction is complete, execute the script before submission.
Pre-Lock
Execute the script before locking the file.
Pre-revprop-change
Run the script before modifying the revision attribute.
Pre-Unlock
Execute this script before unlocking the file.
Start-commit
Run this script before the client has submitted data to the server, that is, before creating a subversion transaction (txn ).
Specifically, in our application scenarios, we need to implement a synchronous test server. After a user completes a commit operation, let the hook program automatically update the file on the test server!
Attached is my SVN directory introduction:
192.168.1.20 is the internal server of our company (SVN + Web). The root directory of SVN is svndate (svndate is the version directory, and you can directly access 192.168.1.20 using the svn client)
The auth file is (this shows that svndate is the root directory. Pay attention to the document directory, which is shown in the previous figure ):