Skip to content

Instantly share code, notes, and snippets.

@bshaffer
Created January 12, 2011 16:50
Show Gist options
  • Save bshaffer/776439 to your computer and use it in GitHub Desktop.
Save bshaffer/776439 to your computer and use it in GitHub Desktop.
tag from svn
### USAGE ###
#
# tag [-u username] [-p password] repository version [last-version]
#
# Typing in -u but not -p will prompt you for a password.
# Priving a last-version argument will create a diff file between the new version and last-version tag.
# repository is automatically appended to REPOROOT.
REPOROOT=http://myrepo.com
username=
password=
while getopts 'u:p:' OPTION
do
case $OPTION in
u) username="--username $OPTARG"
;;
p) password="--password $OPTARG"
;;
?) printf "Usage: %s: [-u username] [-p password] args\n" $(basename $0) >&2
exit 2
;;
esac
done
shift $(($OPTIND - 1))
export repo=$1
export to_version=$2
export from_version=$3
if [ "$repo" == "" ] ; then
echo "Please provide a repository as a first argument. This will be appended to $REPOROOT"
exit
fi
if [ "$to_version" == "" ]; then
echo "Please provide the name of your release as a second argument. This will also be the name of your tag."
exit
fi
if [[ !$username ]]; then
read -p "Username: " un
export username="--username $un"
fi
if [[ !$password ]]; then
read -s -p "Password: " pw
export password="--password $pw"
fi
export new_path="$repo-$to_version"
echo "Exporting version $to_version to $new_path"
svn export $REPOROOT/$repo/trunk $new_path $username $password
echo "Tagging version $to_version"
svn import $new_path $REPOROOT/$repo/tags/$to_version -m "tagging version $to_version" $username $password
if [ $from_version ] ; then
svn diff $REPOROOT/$repo/tags/$from_version $REPOROOT/$repo/tags/$to_version $username $password > $from_version-$to_version.diff
fi
echo "Diff Created. Removing Exported Directory $new_path"
rm -Rf $new_path
echo "Complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment