luci-base: fix wrong pattern of urlencode() (encode '+' properly) #182
[project/luci.git] / build / mkrevision.sh
1 #!/bin/sh
2
3 TOPDIR="${0%mkrevision.sh}"
4
5 [ -d "$TOPDIR/../build" ] || {
6         echo "Please execute as ./build/mkrevision.sh" >&2
7         exit 1
8 }
9
10 (
11         cd "$TOPDIR"
12         if svn info >/dev/null 2>/dev/null; then
13                 revision="svn-r$(LC_ALL=C svn info | sed -ne 's/^Revision: //p')"
14         elif git log -1 >/dev/null 2>/dev/null; then
15                 revision="svn-r$(LC_ALL=C git log -1 | sed -ne 's/.*git-svn-id: .*@\([0-9]\+\) .*/\1/p')"
16                 if [ "$revision" = "svn-r" ]; then
17                         set -- $(git log -1 --format="%ct %h")
18                         secs="$(($1 % 86400))"
19                         yday="$(date --utc --date="@$1" "+%y.%j")"
20                         revision="$(printf 'git-%s.%05d-%s' "$yday" "$secs" "$2")"
21                 fi
22         else
23                 revision="unknown"
24         fi
25
26         echo "$revision"
27 )