Last active
August 29, 2015 13:59
-
-
Save jdrydn/10719672 to your computer and use it in GitHub Desktop.
Extending SVN's features to include common tasks such as tagging.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Just overriding the main SVN command | |
# So we can catch any requests to tag | |
# @javajawa++ | |
function svn | |
{ | |
case "$1" in | |
tag) | |
if [ ! -d ".svn" ]; then | |
echo "Not in an SVN directory. Navigate to an SVN folder and try again." | |
return 1 | |
fi | |
REPO=`svn info | grep 'URL' | awk '{print $NF}' | sed 's/.\{6\}$//'` | |
TAG=`svn ls $REPO/tags | sed 's|[^0-9.]||g' | sort -uV | tail -n 1` | |
echo "!!! LISTEN UP !!!" | |
echo "This tagging script expects some things to be in place when you use it." | |
echo "For starters, you must have checked out the TRUNK folder located at $REPO in order to successfully tag." | |
echo "Otherwise, you'll break stuff when it tries to find a /tags folder." | |
echo "YOU HAVE BEEN WARNED!" | |
echo | |
echo "SVN repository: $REPO" | |
echo "The current tag for $REPO is $TAG" | |
echo -n "New tag: " | |
read NTAG | |
echo "Tagging $REPO trunk as $NTAG" | |
svn cp $REPO/trunk $REPO/tags/$NTAG -m "Tagging trunk as $NTAG." --quiet | |
if [ "$2" = "live" ]; then | |
echo "Tagging $REPO $NTAG as live" | |
svn rm $REPO/tags/live -m "Removing live tag." --quiet | |
svn cp $REPO/tags/$NTAG $REPO/tags/live -m "Promoting $NTAG to live." --quiet | |
fi | |
return 0 | |
;; | |
*) command svn $* ;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment