Created
December 10, 2015 13:47
-
-
Save rmpel/77662cd3158f48f30838 to your computer and use it in GitHub Desktop.
script to easily tag a Subversion project
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 | |
SVN=/usr/local/bin/svn | |
[ ! -f "$SVN" ] && SVN=/usr/bin/svn | |
trunk_or_branch_status () { | |
echo "Status on SVN ($1)" | |
TRUNKREV=` svn info "$1" | grep "Last Changed Rev" | egrep -o [0-9]+ ` | |
TAGSREV=` svn info "$2"/tags | grep "Last Changed Rev" | egrep -o [0-9]+ ` | |
[ $TRUNKREV -gt $TAGSREV ] && echo There are changes not yet tagged \! \( HEAD: $TRUNKREV, Tags: $TAGSREV \) && svn log -r $TAGSREV:$TRUNKREV | |
[ $TRUNKREV -le $TAGSREV ] && echo No action needed\! | |
} | |
[ ! -d ".svn" ] && echo Use only inside the main project directory under SVN control && exit | |
S=` $SVN info | grep URL: | cut -d " " -f 2 ` | |
BSE=` echo $S | sed 's/\/trunk/ /' | sed 's/\/branches/ /' | sed 's/\/tags/ /' | cut -d " " -f 1 ` | |
B=$BSE/tags | |
T=$BSE/tags/$1 | |
[ "$1" == "" ] && echo Usage: $0 TAG Commit comment && echo latest tags: && $SVN ls "$B" | tail -n 5 | |
[ "$1" == "" ] && trunk_or_branch_status "$S" "$BSE" | |
[ "$1" == "" ] && exit | |
IFS=$'\n'; | |
tags=` $SVN ls $B ` | |
for i in $tags; do | |
lasttag=$i | |
done | |
lasttag=` echo $lasttag | sed 's_/__g' ` | |
for i in $tags; do | |
[ "$1/" == "$i" ] && echo tag $1 already exists, please create a tag higher than $lasttag && exit; | |
done | |
M=$@ | |
echo Executing: $SVN cp "$S" "$T" -m "Release $M" | |
$SVN cp "$S" "$T" -m "Release $M" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script can be used to easily create a tag from within the working-copy (checkout) of the trunk of a project.
Syntax:
svntag.sh 0.0.3
to tag version 0.0.3
The script was developed with WordPress in mind; for themes, style.css is checked for a matching version number, for plugins, all php files in the root are checked (no file-naming-convention exists for this)
Checks are done to prevent errors;
important to know that there is NO check for old version numbers; if you have a tag 0.0.3 and 1.0.0, you CAN tag 0.0.4 through 0.9.9, but this probably is not very good practice :P