2008-03-31 21:50:05 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Print additional version information for non-release trees.
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "Usage: $0 [srctree]" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
cd "${1:-.}" || usage
|
|
|
|
|
|
|
|
# Check for git and a git repo.
|
2009-02-03 17:24:13 +01:00
|
|
|
if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
|
2008-03-31 21:50:05 +02:00
|
|
|
# Do we have an untagged version?
|
|
|
|
if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
|
2009-02-03 17:24:13 +01:00
|
|
|
if tag=`git describe 2>/dev/null`; then
|
|
|
|
echo $tag | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
|
|
|
|
else
|
|
|
|
printf '%s%s' -g $head
|
|
|
|
fi
|
2008-04-01 11:53:14 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Is this git on svn?
|
|
|
|
if git config --get svn-remote.svn.url >/dev/null; then
|
2009-03-26 21:47:38 +01:00
|
|
|
printf -- '-svn%s' "`git svn find-rev $head`"
|
2008-03-31 21:50:05 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Are there uncommitted changes?
|
|
|
|
git update-index --refresh --unmerged > /dev/null
|
|
|
|
if git diff-index --name-only HEAD | grep -v "^scripts/package" \
|
|
|
|
| read dummy; then
|
|
|
|
printf '%s' -dirty
|
|
|
|
fi
|
|
|
|
|
|
|
|
# All done with git
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for mercurial and a mercurial repo.
|
|
|
|
if hgid=`hg id 2>/dev/null`; then
|
|
|
|
tag=`printf '%s' "$hgid" | cut -d' ' -f2`
|
|
|
|
|
|
|
|
# Do we have an untagged version?
|
|
|
|
if [ -z "$tag" -o "$tag" = tip ]; then
|
|
|
|
id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
|
|
|
|
printf '%s%s' -hg "$id"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Are there uncommitted changes?
|
|
|
|
# These are represented by + after the changeset id.
|
|
|
|
case "$hgid" in
|
|
|
|
*+|*+\ *) printf '%s' -dirty ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# All done with mercurial
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for svn and a svn repo.
|
2012-01-16 13:54:57 +01:00
|
|
|
if rev=`LC_ALL=C svn info 2>/dev/null | grep '^Last Changed Rev'`; then
|
2008-03-31 21:50:05 +02:00
|
|
|
rev=`echo $rev | awk '{print $NF}'`
|
2012-01-16 13:54:57 +01:00
|
|
|
changes=`LC_ALL=C svn status 2>/dev/null | grep '^[AMD]' | wc -l`
|
2008-03-31 21:50:05 +02:00
|
|
|
|
|
|
|
# Are there uncommitted changes?
|
|
|
|
if [ $changes != 0 ]; then
|
2009-02-03 17:24:13 +01:00
|
|
|
printf -- '-svn%s%s' "$rev" -dirty
|
2008-03-31 21:50:05 +02:00
|
|
|
else
|
|
|
|
printf -- '-svn%s' "$rev"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# All done with svn
|
|
|
|
exit
|
|
|
|
fi
|