4 [ -n "$TOPDIR" ] && cd $TOPDIR
9 [ -f version
] ||
return 1
15 REBOOT
=ee53a240ac902dc83209008a2671e7fdcf55957a
16 git rev-parse
--git-dir >/dev
/null
2>&1 ||
return 1
18 [ -n "$GET_REV" ] || GET_REV
="HEAD"
22 GET_REV
="$(echo $GET_REV | tr -d 'r')"
23 BASE_REV
="$(git rev-list ${REBOOT}..HEAD | wc -l | awk '{print $1}')"
24 REV
="$(git rev-parse HEAD~$((BASE_REV - GET_REV)))"
27 BRANCH
="$(git rev-parse --abbrev-ref HEAD)"
28 ORIGIN
="$(git rev-parse --verify --symbolic-full-name ${BRANCH}@{u} 2>/dev/null)"
29 [ -n "$ORIGIN" ] || ORIGIN
="$(git rev-parse --verify --symbolic-full-name master@{u} 2>/dev/null)"
30 REV
="$(git rev-list ${REBOOT}..$GET_REV | wc -l | awk '{print $1}')"
32 if [ -n "$ORIGIN" ]; then
33 UPSTREAM_BASE
="$(git merge-base $GET_REV $ORIGIN)"
34 UPSTREAM_REV
="$(git rev-list ${REBOOT}..$UPSTREAM_BASE | wc -l | awk '{print $1}')"
39 if [ "$REV" -gt "$UPSTREAM_REV" ]; then
40 REV
="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
43 REV
="${REV:+r$REV-$(git log --format="%h" -1)}"
51 [ -d .hg
] ||
return 1
52 REV
="$(hg log -r-1 --template '{desc}' | awk '{print $2}' | sed 's/\].*//')"
57 try_version || try_git || try_hg || REV
="unknown"