diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2013-03-25 11:05:34 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2013-03-25 11:05:34 +0000 |
commit | cf99c53a74544ac557a934300dc4f37bc81739a3 (patch) | |
tree | 4d749cd188be1c74e7707263b86664bc1a9feb9f /build | |
parent | fdf7d6618d9f46321c3aaffe6d177ceb30fc71cb (diff) |
build: add mkrevision.sh helper script which properly infers the revision from either svn, git-svn or git work copies
Diffstat (limited to 'build')
-rwxr-xr-x | build/mkrevision.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/build/mkrevision.sh b/build/mkrevision.sh new file mode 100755 index 000000000..889ce75c2 --- /dev/null +++ b/build/mkrevision.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +TOPDIR="${0%mkrevision.sh}" + +[ -d "$TOPDIR/../build" ] || { + echo "Please execute as ./build/mkrevision.sh" >&2 + exit 1 +} + +( + cd "$TOPDIR" + if svn info >/dev/null 2>/dev/null; then + revision="svn-r$(LC_ALL=C svn info | sed -ne 's/^Revision: //p')" + elif git log -1 >/dev/null 2>/dev/null; then + revision="svn-r$(LC_ALL=C git log -1 | sed -ne 's/.*git-svn-id: .*@\([0-9]\+\) .*/\1/p')" + if [ "$revision" = "svn-r" ]; then + revision="git-$(LC_ALL=C git log -1 --pretty=%h)" + fi + else + revision="unknown" + fi + + echo "$revision" +) |