From: Felipe Contreras Date: Fri, 14 Apr 2023 12:18:37 GMT Subject: [PATCH 14/18] version-gen: refactor main functionality Message-ID: <20230414121841.373980-15-felipe.contreras@gmail.com> In-Reply-To: <20230414121841.373980-1-felipe.contreras@gmail.com> 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 --- GIT-VERSION-GEN | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index fa0e72a32c..53b3d64131 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -3,18 +3,12 @@ GVF=GIT-VERSION-FILE DEF_VER=2.40.GIT -describe () { +get_version () { + test -f version && cat version && 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) -else - VN=$(describe) -fi +VN=$(get_version) : "${VN:=$DEF_VER}" -- 2.40.0+fc1