From 121b8fffa640e1f780febe62d9e7b609ee39c582 Mon Sep 17 00:00:00 2001 From: Daniel Rainer Date: Mon, 2 Mar 2026 17:12:51 +0100 Subject: [PATCH] fix: version test on shallow, dirty git repo In shallow, dirty git repo, the version identifier will look something like `fish, version 4.5.0-g971e0b7-dirty`, with no commit counter indicating the commits since the last version. Our regex did not handle this case. Make the commit counter optional, which also allows removing the second alternative in the regex, since it's now subsumed by the first. Fixes #12497 Closes #12498 --- tests/checks/version.fish | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/checks/version.fish b/tests/checks/version.fish index 17521d9e4..34bade157 100644 --- a/tests/checks/version.fish +++ b/tests/checks/version.fish @@ -6,10 +6,11 @@ # 1.2.3-42-gdeadbeef # Git version when no tags are present. Distros should probably not package it like this. # 1.2.3-gdeadbeef +# If the git commit hash is part of the version identifier, it may have a `-dirty` suffix. $fish -v -# CHECK: fish, version {{\d+\.\d+\.\d+(-\d+-g[0-9a-f]{7,}(-dirty)?|-g[0-9a-f]{7,})?$}} +# CHECK: fish, version {{\d+\.\d+\.\d+((-\d+)?-g[0-9a-f]{7,}(-dirty)?)?$}} set -l workspace_root (status dirname)/../.. $workspace_root/build_tools/git_version_gen.sh -# CHECK: {{\d+\.\d+\.\d+(-\d+-g[0-9a-f]{7,}(-dirty)?|-g[0-9a-f]{7,})?$}} +# CHECK: {{\d+\.\d+\.\d+((-\d+)?-g[0-9a-f]{7,}(-dirty)?)?$}}