#! /bin/csh -f # mkrel (C shell script) -- create a tag in SVN for a given release based on the most recent entry in relnotes.txt # Usage: mkrel [ -u ] [ ] # Options # -u ignore uncommitted changes # -v show the tag that was calculated from $notesfile # # TO-DO # allow notesfile and svnsource to be specified # read from the command line set self = `basename $0` set allowed_options = uv # process options eval set argv = \(`getopt -n $self -s csh +$allowed_options $*:q`\) if ($status != 0) exit 1 # getopt would have already reported the error set svnsource=trunk set notesfile=relnotes.txt while (x$1:q != x--) switch ($1) case -u: set ignore_mods__t breaksw case -v: set verbose__t breaksw endsw shift # get rid of the option (or its arg if the inner shift already got rid it) end shift # get rid of the "--" # process remaining args set svnrepo=$1 set version=$2 # == sanity checks == if (! -r $notesfile) then sh -c "echo ${self}: release notes not found >&2" exit 2 endif svn st | grep -q '^[^?]' if ($status == 0 && ! $?ignore_mods__t) then sh -c "echo ${self}: uncommitted changes found >&2" exit 3 endif # == processing == ## set reltag=v$version set reltag=`sed -n -e '/^Version \([^ ]*\) - .*/ {' -e 's//v\1/p' -e q -e '}' $notesfile` # search for the release tag in the repo's tags subdir, as a plain string, with a # slash on the end (as placed onto the end of directories by 'svn ls') to avoid # partial matches (since $reltag starts with a "v", we don't have to anchor) svn ls $svnrepo/tags/ | grep -F -q $reltag/ if ($status == 0) then sh -c "echo ${self}: release tag '$reltag' already exists >&2" else if ($?verbose__t) echo Creating tag $svnrepo/tags/$reltag svn cp -m "branch tags/$reltag created by $self" $svnrepo/$svnsource $svnrepo/tags/$reltag endif # note: match on 'svn ls' result could be done as below, i.e. using a sanitised regexp ## set reltag_regexp=`echo $reltag | sed 's/\./\./g'` ## svn ls $svnrepo/tags/ | grep -q ^$reltag_regexp:q/