forked from pramodk/nrn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit2nrnversion_h.sh
More file actions
executable file
·29 lines (25 loc) · 911 Bytes
/
Copy pathgit2nrnversion_h.sh
File metadata and controls
executable file
·29 lines (25 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
a=$1
if test "$a" = "" ; then
a=.
fi
cd $a
if git log > /dev/null && test -d .git ; then
describe="`git describe --tags`"
branch="`git rev-parse --abbrev-ref HEAD`" # branch name
modified="`git status -s -uno --porcelain | sed -n '1s/.*/+/p'`" # + if modified
gcs=`git log --format="%h" -n 1` #short commit hash
d="`git log --format="%ad" -n 1 --date=short`" # date
echo "#define GIT_DATE \"$d\""
echo "#define GIT_BRANCH \"$branch\""
echo "#define GIT_CHANGESET \"${gcs}${modified}\""
echo "#define GIT_DESCRIBE \"${describe}${modified}\""
elif test -f src/nrnoc/nrnversion.h ; then
sed -n '1,$p' src/nrnoc/nrnversion.h
else
echo "#define GIT_DATE \"1999-12-31\""
echo "#define GIT_BRANCH \"?\""
echo "#define GIT_CHANGESET \"?\""
echo "#define GIT_DESCRIBE \"?\""
exit 1
fi