Skip to content

Instantly share code, notes, and snippets.

@rhowardiv
Created October 3, 2011 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhowardiv/1260128 to your computer and use it in GitHub Desktop.
Save rhowardiv/1260128 to your computer and use it in GitHub Desktop.
Fetch latest tags from a directory in a Subversion repository and show them with their source path and rev#
#!/bin/bash
#
# Fetch latest N tags and show from where and which revision they were copied
function usage()
{
echo "
Usage: $0 [-n N] URL [REGEX]
-n Number of tags to fetch
URL Directory to look under
REGEX Filter for tagnames"
}
LINES=10
while getopts "n:" optname
do
case "$optname" in
"n")
LINES=$OPTARG
shift 2
;;
*)
usage
break
esac
done
URL=$1
GREPFOR=$2
LIST=$(svn list -v "$URL" | grep "$GREPFOR" | grep -v " ./$" | sort -n | tail -n $LINES | awk '{print $6}')
for i in $LIST
do
TAGREV=$(\
svn log -v --stop-on-copy "$URL/$i" | tac | \
grep -m 1 -P '\(from [^:]+:\d+\)' | \
sed 's/^.\+from \(.\+:\([0-9]\+\)\))/\1/'\
)
printf "%-22s\t%40s\n" $i $TAGREV
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment