Skip to content

Commit 7241d99

Browse files
nmreadelfauxten
authored andcommitted
feat: get latest tag by git rev-list
1 parent 7682fec commit 7241d99

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

setup.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ def get_python_ext_suffix():
3333

3434
def get_latest_git_tag(minor_ver_auto=False):
3535
try:
36-
completed_process = subprocess.run(['git', 'describe', '--tags', '--abbrev=0', '--match', 'v*'], capture_output=True, text=True)
36+
# get latest tag commit
37+
completed_process = subprocess.run(['git', 'rev-list', '--tags', '--max-count=1'], capture_output=True, text=True)
38+
if completed_process.returncode != 0:
39+
print(completed_process.stdout)
40+
print(completed_process.stderr)
41+
# get git version
42+
raise RuntimeError("Failed to get git latest tag commit ")
43+
output = completed_process.stdout.strip()
44+
# get latest tag name by commit
45+
completed_process = subprocess.run(['git', 'describe', '--tags', f"{output}"], capture_output=True, text=True)
3746
if completed_process.returncode != 0:
3847
print(completed_process.stdout)
3948
print(completed_process.stderr)

0 commit comments

Comments
 (0)