瀏覽代碼

scripts/getver.sh: improve revision output

Change the revision output to r<upstream-revision>+<local commits> so
it is easier to get the base revision (and see if there are local
commits).

Example:
$ ./scripts/getver.sh
r794+3
$

Signed-off-by: Jonas Gorski <[email protected]>
Jonas Gorski 9 年之前
父節點
當前提交
15b88df87f
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      scripts/getver.sh

+ 7 - 2
scripts/getver.sh

@@ -23,9 +23,14 @@ try_git() {
 		REV="$(git rev-parse HEAD~$((BASE_REV - GET_REV)))"
 		;;
 	*)
-
+		UPSTREAM_BASE="$(git merge-base $GET_REV origin/master)"
+		UPSTREAM_REV="$(git rev-list reboot..$UPSTREAM_BASE --count)"
 		REV="$(git rev-list reboot..$GET_REV --count)"
-		REV="${REV:+r$REV}"
+		if [ -n "$REV" -a -n "$UPSTREAM_REV" -a "$REV" -gt "$UPSTREAM_REV" ]; then
+			REV="r${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
+		else
+			REV="${REV:+r$REV}"
+		fi
 		;;
 	esac