fix: only remove the 'v' prefix from the git tag name (#45132)

In the old version of get-version.js, it replaces the leading 'v',
i.e. |output.stdout.toString().trim().replace(/^v/g, '')|. However,
in the new version of get-git-version.py, it directly replaces all
'v'. Obviously, it does not conform to the original semantics.
Although it will not affect the existing electron version calculation,
it may affect other developers' customized git-tag-version, such as
v0.0.0-dev.xxx, which will lose the 'v' of dev.
This commit is contained in:
wujinli 2025-01-14 11:36:03 +08:00 committed by GitHub
parent e57b69f106
commit 5680c628b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@
import subprocess
import os
import re
# Find the nearest tag to the current HEAD.
# This is equivalent to our old logic of "use a value in package.json" for the
@ -24,7 +25,8 @@ try:
cwd=os.path.abspath(os.path.join(os.path.dirname(__file__), '..')),
stderr=subprocess.PIPE,
universal_newlines=True)
version = output.strip().replace('v', '')
# only remove the 'v' prefix from the tag name.
version = re.sub('^v', '', output.strip())
print(version)
except Exception:
# When there is error we print a null version string instead of throwing an