Contrib: Helper scripts to receive the revision ID of the repository without running cmake. Need to be run inside the repository directory.

This commit is contained in:
leak
2010-12-31 02:55:38 +01:00
parent 4b0341c167
commit c5a143547d
2 changed files with 49 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
@echo off &setlocal EnableDelayedExpansion
set usage=Usage: %0 ^<-id ^| -hash^>
set errormsg=Error: No valid revision information found
set cmres=false
if "%1"=="-id" set cmres=true
if "%1"=="-hash" set cmres=true
if not "!cmres!"=="true" (
echo !usage!
exit /B 1
)
for /F "tokens=2,3 delims=-" %%a IN ('"git describe --match=init --abbrev=12"') do (
set res=false
if %%c=="" set res=true
if %%d=="" set res=true
if "!res!"=="true" (
echo !errormsg!
exit /B 1
)
if "%1"=="-id" (
echo %%a
) else if "%1"=="-hash" (
set str=%%b
set str=!str:~1!
echo !str!
)
)
+20
View File
@@ -0,0 +1,20 @@
#/bin/bash
command=$(git describe --match init --abbrev=12)
IFS="-"
cmdarray=($command)
if [ "$1" != "-id" ] && [ "$1" != "-hash" ]; then
echo "Usage: $0 <-id | -hash>"
exit
fi
if [ "${cmdarray[1]}" == "" ] || [ "${cmdarray[2]}" == "" ]; then
echo "Error: No valid revision information found"
exit 1
fi
if [ "$1" == "-id" ]; then
echo ${cmdarray[1]}
elif [ "$1" == "-hash" ]; then
echo ${cmdarray[2]:1}
fi