From 94437278dc7c3635e760f8781e9e151575845cad Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 18 May 2025 12:51:56 +0100 Subject: init.sh: simplify unknown version creation we don't need to read or write a file at all, in that case. we only then need to generate one if running ./mk release. the scenario in which no .git and no version files exist is when someone grabs the build system from a snapshot generated by e.g. forgejo instances. it's ill advised, so we advise against it, but it is mitigated in code. Signed-off-by: Leah Rowe --- include/init.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/init.sh b/include/init.sh index e94157f0..20d63068 100644 --- a/include/init.sh +++ b/include/init.sh @@ -55,10 +55,8 @@ xbmk_get_version() [ ! -f ".version" ] || read -r version < ".version" || :; : [ ! -f ".versiondate" ] || read -r versiondate < ".versiondate" || :; : - [ -e ".git" ] || [ -f ".version" ] || printf "unknown\n" > ".version" \ - || err "Cannot generate unknown .version file" - [ -e ".git" ] || [ -f ".versiondate" ] || printf "1716415872\n" > \ - ".versiondate" || err "Can't generate unknown versiondate file"; : + [ ! -e ".git" ] && [ ! -f ".version" ] && version="unknown" + [ ! -e ".git" ] && [ ! -f ".versiondate" ] && versiondate="1716415872" version_="$version" [ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \ -- cgit v1.2.1