Frage

I am trying to discover the best way to implement a write restriction on a file in subversion.

There will be, over time, many tags and branches of this file. One particular user, user build, must have access to this file (in all possible branches or tags) and nothing else.

i.e., 
svn://app/trunk/changelog.txt
svn://app/branches/1.1/changelog.txt
svn://app/tags/1.2/changelog.txt
etc..

As you can see, this is not a finite set of files, but one file which will be, over time, copied to various branches and tags. We can ensure, however, that the filename is unique in the file tree.

To implement this restriction, on user 'build', for all files named 'changelog.txt', I have thought to implement a pre-commit script.

Is this the best way ?

thanks!

War es hilfreich?

Lösung

The easiest way to do this is by writing a pre-commit hook and putting it in /hooks within the repository.

Subversion will always pass the repository directory and the revision number to your hook.

Pseudobash example:

REPO="$1"
NO="$2"
AUTHOR=`svnlook author $REPO -t "$NO"`
FILES=`svnlook changed -t "$NO" "$REPO" | cut -b2-`


if echo $AUTHOR | grep -q builduser; then
    for FILE in $FILES; do
        if ! echo $FILE | grep -q changelog.txt$; then
            exit 1
        fi
    done
fi

You get the gist of it, I hope.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top