1#!/bin/sh 2 3determineGitRevision() 4{ 5 haikuTop=$1 6 haikuBuildOutputDir=$2 7 8 revision=`cat ${haikuBuildOutputDir}/haiku-revision 2>/dev/null` 9 lastBuiltRevision=`cat ${haikuBuildOutputDir}/last-built-revision \ 10 2>/dev/null` 11 localRev=`git rev-parse HEAD` 12 13 # only determine the haiku-revision if anything has changed from 14 # last build 15 if [ -z "$revision" -o "$lastBuiltRevision" != "$localRev" ]; then 16 # the revision we use is the description of HEAD with respect to the 17 # last reachable hrev-(haiku-revision-)tag 18 revision=`git describe --dirty --tags --match=hrev*` 19 if [ -z "$revision" ]; then 20 # failed to find any hrev tags, use short hash instead 21 revision=`git rev-parse --short HEAD` 22 elif echo "$revision" | grep -- '-' >/dev/null; then 23 # HEAD is not directly a changeset from Haiku's central repo, so we 24 # add the current branch name as additional info 25 branchName=`git branch | grep '*' | cut -b 3-` 26 revision="$revision [$branchName]" 27 fi 28 echo $localRev >${haikuBuildOutputDir}/last-built-revision 29 fi 30} 31 32 33determineHaikuRevision() 34{ 35 haikuTop=$1 36 haikuBuildOutputDir=$2 37 38 case `uname` in 39 Darwin) 40 SED=gsed 41 ;; 42 *) 43 SED=sed 44 ;; 45 esac 46 export SED 47 48 originalDir=`pwd` 49 cd ${haikuTop} 50 export LC_ALL=C 51 if [ -d .svn ]; then 52 revision=`svn info 2>/dev/null | grep Revision | awk '{printf $2}'` 53 elif [ -d .git/svn ]; then 54 revision=`git svn info 2>/dev/null | grep Revision | awk '{printf $2}'` 55 elif [ -d .git ]; then 56 determineGitRevision $haikuTop $haikuBuildOutputDir 57 elif [ -d .hg ]; then 58 # Try searching hg log for last svn commit 59 # Extract from "(svn r12345) ..." line 60 revision=`(cd ${haikuTop} && 61 hg log --no-merges --template "{desc|firstline}\n") 2> /dev/null | 62 grep --max-count=1 "(svn r" | 63 $SED -n -e 's,(svn r\(.*\)).*,\1,p'` 64 fi 65 if [ -z "$revision" ]; then 66 revision=0 67 fi 68 echo $revision >${haikuBuildOutputDir}/haiku-revision 69 cd $originalDir 70} 71