SVN: How to setup a read-only branch in Subversion?
Solution 1:
If you are using Apache to interface your Subversion requests, you can use the Subversion Authorization file to control access to all the tag locations. From there, you can setup your web server to have its own account that is authorized as read-only to the tags folder. You can even goes as far having the web server not even having read access to anything else but the tags directory at certain paths.
If you always create a tag with same name that is used for production deployment, then an svn update will work. Otherwise, you can do an svn switch to go between tags as needed. According to the Subversion book, svn update and svn switch pretty well much do the same thing under the hood.
Now the advantage of using this, you can also provide more granular control of what your developers can and cannot do. You can also control what parts of your repositories is for public read and what parts are not.
If and when you set this up and if your web site is public, be sure to tell your web server to not serve up content in the .svn folders.
Solution 2:
To turn off all commits, add a pre-commit hook script that looks like:
#!/bin/sh
echo "Read-only SVN; no commits allowed!" 1>&2
exit 1
Or if you want to make just one path readonly (like one branch or something), try:
#!/bin/bash
REPOS="$1"
TXN="$2"
if svnlook changed $REPOS -t $TXN |grep -q "mybranch/" ; then
echo "Read-only branch mybranch/; no commits allowed! " 1>&2
exit 1
fi
exit 0
You can, of course, make whatever other checks you want in that if
statement.
Solution 3:
Add a pre-commit hook script that checks a potential commits changed paths and reject commits that commit to your specified branch unless they come from whatever user is authorized to make the branches in question.
You can also do this from the server side repo permissions, how you enact them varies depending on how you expose the repository.