[PATCH v2 13/15] version-gen: refactor main functionality

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's pretty clear that the `version` file overrides `describe`, so do it
in one function.

There's no need for the comment as the code is self-describing.

Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 GIT-VERSION-GEN | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 6bf932c281..5b75cb4976 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -3,19 +3,13 @@
 GVF=GIT-VERSION-FILE
 DEF_VER=2.40.GIT
 
-describe () {
+get_version () {
+	test -f version && cat version && return
+	test -d "${GIT_DIR:-.git}" -o -f .git || return
 	git describe --match "v[0-9]*" --dirty 2>/dev/null | sed -e 's/-/./g' -e 's/^v//'
 }
 
-# First see if there is a version file (included in release tarballs),
-# then try `git describe`, then default.
-if test -f version
-then
-	VN=$(cat version)
-elif test -d "${GIT_DIR:-.git}" -o -f .git
-then
-	VN=$(describe)
-fi
+VN=$(get_version)
 
 : "${VN:=$DEF_VER}"
 
-- 
2.40.0+fc1




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux