#!/bin/sh
# Print additional version information for non-release trees.
#
#  URL: https://172.16.4.12/svn/avcb/tags/a1_bsp-1.0.1/sdk/uboot
#                                                ----- => release version
#  Repository Root: https://172.16.4.12/svn/avcb
#  Repository UUID: f2a560fd-0d73-498b-9854-f0c78103375a
#  Revision: 2712
#  Node Kind: directory
#  Schedule: normal
#  Last Changed Author:
#  Last Changed Rev: 2660
#                   ----- svn-number
#  Last Changed Date: 2011-12-15 18:39:31 +0800 (Thu, 15 Dec 2011)

#  We set version info with tags keyword from URL line 
#  If null, imply that is a trunk version

# Check for svn and a svn repo.
if info=`svn info 2>/dev/null` ; then
	# Try to search tags keywords in ^URL line
	rev=`echo "${info}" | grep '^URL' | grep 'tags'`
	if [ "${rev}" = "" ]; then
		# no tags in ^URL line, get version from ^Revision line
		rev=`echo "${info}" | grep '^Revision' | cut -d':' -f2`
		printf -- 'svn-%s' ${rev}
	else
		#rev=`echo "${rev}" | cut -d'-' -f2 | cut -d'/' -f1`
		rev=`echo "${rev}" | awk -F"a1_bsp-" '{print  $2}' | awk -F'/' '{print $1}'`
		printf -- '%s' ${rev}
	fi
else
	rev=`date +%Y/%m/%d`
	printf -- '%s' ${rev}
fi
