blob: f36fa5ea59b2626a43aacf13f64a155b4012d58f [file] [log] [blame]
Gavin McDonald0b75e1a2010-10-28 02:12:01 +00001#!/bin/sh
2
3#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the
9# "License"); you may not use this file except in compliance
10# with the License. You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing,
15# software distributed under the License is distributed on an
16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21
22cd "`dirname "$0"`"
23
24# Computing both the version and the revision on every invocation is wasteful,
25# but it is cheap and avoids the use of nonportable shell functions.
26
27VERSION=`sed -ne 's/^AC_INIT(\[thrift\], \[\(.*\)\])$/\1/p' configure.ac`
28
29if test -d .svn ; then
30 REVISION="r`svnversion`"
31elif test -d .git ; then
32 SHA1=`git rev-list --max-count=1 --grep='^git-svn-id:' HEAD`
33 REVISION=`git cat-file commit $SHA1 | sed -ne 's/^git-svn-id:[^@]*@\([0-9][0-9]*\).*/r\1/p'`
34 OFFSET=`git rev-list ^$SHA1 HEAD | wc -l | tr -d ' '`
35 if test $OFFSET != 0 ; then
36 REVISION="$REVISION-$OFFSET-`git rev-parse --verify HEAD | cut -c 1-7`"
37 fi
38else
39 REVISION="exported"
40fi
41
42case "$1" in
43 -v) echo $VERSION ;;
44 -r) echo $REVISION ;;
45 -a) echo "$VERSION-$REVISION" ;;
46 *) echo "Usage: $0 -v|-r|-a"; exit 1;;
47esac