Skip to content

Commit 2ad0e84

Browse files
authored
Fix helper for stable releases (#1434)
1 parent 3980ae8 commit 2ad0e84

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tools/helper

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,22 @@ def cli():
2525
logging.basicConfig(level=logging.INFO, format='%(message)s')
2626

2727
pre_release = False
28-
result = subprocess.run('git describe --dirty --tags --long --match "v*.*.0"', shell=True, capture_output=True, check=True, text=True)
28+
result = subprocess.run('git describe --dirty --tags --long --match "v*.*"', shell=True, capture_output=True, check=True, text=True)
2929
git_tag = result.stdout.rstrip()
30-
logging.debug("git describe returned: %s", git_tag)
30+
logging.debug('git describe (with --match "v*.*") returned: %s', git_tag)
3131
tag, commits_since, suffix = git_tag.split("-", 2)
3232
version = tag[1:]
3333
version_info = [int(x) for x in version.split(".")]
3434
if "-dirty" in suffix or commits_since != "0":
3535
pre_release = True
36-
if pre_release:
36+
# If pre_release = True, we need to calculate the time difference from the first stable release of the month with a "*.0" tag
37+
result = subprocess.run('git describe --dirty --tags --long --match "v*.*.0"', shell=True, capture_output=True, check=True, text=True)
38+
git_tag = result.stdout.rstrip()
39+
logging.debug('git describe (with --match "v*.*.0") returned: %s', git_tag)
40+
tag, commits_since, suffix = git_tag.split("-", 2)
41+
version = tag[1:]
42+
version_info = [int(x) for x in version.split(".")]
43+
3744
if len(version_info) == 2:
3845
version_info.append(0)
3946
if len(version_info) != 3:

0 commit comments

Comments
 (0)