9
9
# set version parts to defaults for CVS snapshot
10
10
major_version=`cat ${srcdir}/major_version`
11
minor_version_proto=`cat ${srcdir}/minor_version`
11
12
DATE=`date +%Y%m%d`
13
14
#echo $major_version
14
15
#echo $minor_version
16
if test -d "${srcdir}/CVS"; then
17
# get the date/branch/version tag
18
rawtag=`cat ${srcdir}/CVS/Entries | grep major_version | sed -e "s,/major_version/.*/.*/.*/,,"`
20
# determine the type of the tag
21
echo $rawtag | grep "^D" > /dev/null && tagtype=D
22
#echo $rawtag | grep "^Tb" > /dev/null && tagtype=Tb
23
echo $rawtag | grep "^Tv" > /dev/null && tagtype=Tv
27
tag=`echo $rawtag | sed -e "s,^$tagtype,,"`
30
# date tag: make it a date dagged alpha release
31
if test "$tagtype" = D; then
32
DATE=`echo $tag | sed -e "s,\...\...\...\$,," | sed -e "s,\.,,g"`
33
minor_version=`cat ${srcdir}/minor_version | sed -e "s,DATE,$DATE," -e "s,YYYYMMDD,$DATE,"`
36
# version tag: take whole version, replace _[number] with .[number]
37
if test "$tagtype" = Tv; then
38
major_version=`echo $tag | sed -e "s,_\([0-9]\),\.\\1,g"`
44
if test -d "${srcdir}/.svn" || test -d "${srcdir}/../.svn"; then
45
# get the inter-repository path by parsing the URL
47
URL=`svn info ${srcdir} | grep ^URL | sed -e 's,^URL: ,,'`
49
# uncomment the followint URLs to test various cases
51
# URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/trunk/armagetronad
53
# URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/branches/0.4/armagetronad
56
# URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/tags/0.2.8.2/armagetronad
59
REPOPATH=`echo $URL | sed -e 's,/armagetronad$,,' -e 's,.*/armagetronad/,,'`
60
#echo REPOPATH=$REPOPATH
63
if echo $REPOPATH | grep '^tags/' > /dev/null; then
65
major_version=`echo $REPOPATH | sed -e 's,^tags/,,'`
69
# make revision the alpha tag
70
REVISION=`svn info ${srcdir} | grep ^Revision | sed -e 's,^Revision: ,,'`
73
if echo $REPOPATH | grep '^branches/' > /dev/null; then
75
branch=`echo $REPOPATH | sed -e 's,^branches/,,'`
76
# branch 0.2.8 produces 0.2.9 versions. Confusing, yeah, but moving it
77
# in the repo is too risky.
78
if test ${branch} = "0.2.8"; then
79
# try to get revision ID from bzr using the magic bzr-svn marker
80
# (only works this way on 0.2.8)
81
REVISION=`svn propget bzr:revision-id:v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs ${srcdir} | tail -n 4 | sed -e 's, .*,,' | grep [0-9] | tail -n 1`
83
major_version=${branch}
89
#echo REVISION=$REVISION
90
minor_version=_alpha_r$REVISION
22
test -z "$limit" || limit="-l $limit"
24
count=$(bzr log --include-merges --line $limit "${srcdir}" 2>/dev/null | wc -l)
95
28
# *TODO* once we get our superproject up on launchpad (and thus get saner branch nicks), use branch nicks for $major_version
96
29
# Check if bzr is installed, and if the path is versionned
97
bzr info ${srcdir} >/dev/null 2>&1
98
31
# But for now, ignore it
32
if test $? -eq 0 && test -d ${srcdir}/.bzr
103
revno=`bzr revno ${srcdir}`
35
# Crappily, we can't rely on revision numbers to do anything
36
# ( ie. when one merges then pushes, the last revno might be lower than originally)
37
# So we count revisions, including merged ones, also including fools which have empty
38
# lines with only "revno: 15" in their commit messages
39
revno=$( bzr revno ${srcdir} 2>/dev/null)
40
revcount=$( bzr_count_revisions ${srcdir} )
44
branchurl=$( bzr info ${srcdir} 2>/dev/null | sed -ne 's/^ parent branch: \(.*\)$/\1/p' )
47
# We will check this branch diverged, and/or if tree changed
48
bzrmissingcout=$( cd ${srcdir} && bzr missing --this 2>/dev/null )
105
50
bzr diff ${srcdir} --quiet >/dev/null 2>&1
106
# Test for the return code of bzr diff (see bzr diff --help)
109
# If no change was made, use revision number (with offset to match svn revno)
110
# but first check if it's tagged
54
if test ${missing} -eq 1
57
# Count the revisions we added locally
58
localrevisions=$( echo "${bzrmissingcout}" | sed -ne '2,1s/[^0-9]//gp' )
59
# See how many steps it is, with the fool's number
60
stepsbackwards=$( bzr_count_revisions ${srcdir} ${localrevisions} )
62
minor_version=_alpha_z$(( ${revcount} - ${stepsbackwards} ))_${DATE}
63
# Set last common ancestors
64
lca=$(( ${revno} - ${localrevisions}))
65
lcaz=$(( ${revcount} - ${stepsbackwards} ))
67
elif test ${missing} -eq 0 && ( test ${changed} -eq 1 || test ${changed} -eq 2 )
69
# If a change was made and no more revision was added, just use revision fool's number plus build date
70
minor_version=_alpha_z${revcount}_${DATE}
71
# And this is versionned too
73
elif test ${missing} -eq 0
75
# If really no change was made, use the fool's number, with tag if any
76
# So check if we have tags
77
revno=$(bzr revno ${srcdir})
111
78
tag=$(bzr tags -r $revno | awk '{ print $1 }')
114
81
# If it is tagged, use the tag
82
minor_version=_alpha_z${revcount}_${tag}
117
# If not, use revision number
84
# If not, use fool's number only
85
minor_version=_alpha_z${revcount}
87
# That's versioned as well
89
# Otherwise, this is just not versionned
122
# If a change was made, use revision number plus build date
123
DATE=_r${revno}_$DATE
124
# It returns 3 if it's not versionned, so forget it
95
branchnick=$( cd ${srcdir}; bzr nick )
96
revid=$( bzr testament | sed -ne 's/^revision-id: \(.*\)/\1/p' )
100
if test -d "${srcdir}/.git"; then
103
# todo: once we have make tags, consider just git describe --tags as version ID.
104
if tag=`git describe --tags --candidates=0` > /dev/null 2>&1; then
105
major_version=`echo ${tag} | sed -e s/version_// -e s/release_//`
109
if git diff-index --quiet HEAD --; then
110
# local checkout clean, just use revno
111
DATE=_z`git rev-list HEAD --count`
113
# local changes, add date
114
DATE=_z`git rev-list HEAD --count`_$DATE
128
119
if test -z "$minor_version"
130
test -z "$DATE" || minor_version=`cat ${srcdir}/minor_version | sed -e "s,DATE,$DATE," -e "s,YYYYMMDD,$DATE,"`
121
test -z "$DATE" || minor_version=`echo ${minor_version_proto} | sed -e "s,DATE,$DATE," -e "s,YYYYMMDD,$DATE,"`
133
124
echo $major_version$minor_version