Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
drunken-octo-hipster/build/mkrevision.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
27 lines (23 sloc)
668 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
set -- $(git log -1 --format="%ct %h") | |
secs="$(($1 % 86400))" | |
yday="$(date --utc --date="@$1" "+%y.%j")" | |
revision="$(printf 'git-%s.%05d-%s' "$yday" "$secs" "$2")" | |
fi | |
else | |
revision="unknown" | |
fi | |
echo "$revision" | |
) |