Subversion: Difference between revisions
Created page with 'Really, [http://subversion.tigris.org/ subversion] is no longer where it's at (although it's an excellent replacement for [http://www.nongnu.org/cvs/ cvs], should any unfortunate...' |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Really, [http://subversion.tigris.org/ subversion] is no longer where it's at (although it's an excellent replacement for [http://www.nongnu.org/cvs/ cvs], should any unfortunate souls still be using that in this day and age). Try distributed source code control systems like [http://git-scm.com/ git]. | Really, [http://subversion.tigris.org/ subversion] is no longer where it's at (although it's an excellent replacement for [http://www.nongnu.org/cvs/ cvs], should any unfortunate souls still be using that in this day and age). Try distributed source code control systems like [http://git-scm.com/ git]. | ||
==Using subversion with build processes== | |||
* Realize that most subversion software, including <tt>svnversion</tt> and <tt>svn-clean</tt>, rely on the <tt>.svn</tt> metadata embedded in checkouts to operate properly. Bundling up this metadata will, generally, roughly double the size of distributed tarballs (especially for repositories with much binary data). | |||
==Keeping $HOME in subversion== | ==Keeping $HOME in subversion== | ||
* ''Don't'' keep transient files under control, particularly things like browser cache or [[bash]] history. | * ''Don't'' keep transient files under control, particularly things like browser cache or [[bash]] history. | ||
* ''Don't'' keep things like [[OpenSSH|ssh]] and [http://www.gnupg.org/ GnuPG] keys in there; use symbolic links and a second repository | * ''Don't'' keep things like [[OpenSSH|ssh]] and [http://www.gnupg.org/ GnuPG] keys in there; use symbolic links and a second repository | ||
==XML svn logs== | |||
As noted on the [[xmlstarlet]] page, svn can generate well-formed XML output for its log command. This can be very handy for writing robust scripts. Use <tt>--xml</tt> to generate XML, and <tt>-v</tt> to provide additional data (files edited, etc). | |||
===Recipes=== | |||
* '''All commits from a given authorname USER, with details''' | |||
** <code>svn log -d --xml | xml sel -t -c "//logentry[author='USER']"</code> | |||
* '''All commits to a given repopath PATH, with details''' | |||
** <code>svn log -d --xml | xml sel -t -c "//logentry[paths/path='PATH']" | |||
==Hook Examples== | |||
===Pre-commit=== | |||
<pre>#!/bin/sh | |||
umask 0002 || exit 1 | |||
REPOS="$1" | |||
TXN="$2" | |||
# must use log messages you aloof little bitches | |||
svnlook log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" || { echo "Empty logfiles are disallowed." >&2 ; exit 1 ; }</pre> | |||
[[Category:Source Control]] | |||
===Post-commit=== | |||
<pre>#!/bin/bash | |||
set -e | |||
set -o nounset | |||
set -o pipefail | |||
umask 0002 | |||
export REPOS="$1" | |||
export REV="$2" | |||
LASTREV="$(($REV - 1))" | |||
REPONAME="`basename $REPOS`" | |||
MSG="`svn log --xml -r$REV file://$REPOS | xmlstarlet sel -t -v //msg`" | |||
TITLE="`echo $MSG | cut -b-56`" | |||
AUTHOR="`svn log --xml -r$REV file://$REPOS | xmlstarlet sel -t -v //author`" | |||
AUTHORMAIL="`finger -m -p $AUTHOR | head -n1 | cut -d: -f3- | cut -b2-` <$AUTHOR@providence.research.sys>" | |||
( echo -e "From: $AUTHORMAIL" && \ | |||
echo "Subject: [$REPONAME-$REV] $TITLE" && \ | |||
echo -e "\n" && echo "`echo $MSG | fmt -w72 - `" && echo && \ | |||
svn diff file://$REPOS@$LASTREV file://$REPOS@$REV && \ | |||
echo -e "\n-- \ngenerated by $0 on $HOSTNAME\nreport bugs to nblack@securecomputing.com" \ | |||
) | snmail -s -c "$REPONAME" sys.research.subversion.</pre> | |||