Skip to content

Commit eec6bd4

Browse files
authored
CXX-3099 perform refname:strip=2 within Python (#1392)
1 parent 5c47a41 commit eec6bd4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

etc/calc_release_version.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,14 @@ def iter_tag_lines():
250250
the second is a tag that is associated with that commit. Duplicate commits
251251
are possible.
252252
"""
253-
output = check_output(['git', 'for-each-ref', '--format=%(*objectname)|%(objectname)|%(refname:strip=2)', 'refs/tags/*'])
253+
output = check_output(['git', 'for-each-ref', '--format=%(*objectname)|%(objectname)|%(refname)', 'refs/tags/*'])
254254
lines = output.splitlines()
255255
for l in lines:
256-
obj, tagobj, tag = l.split('|', 2)
256+
obj, tagobj, rawtag = l.split('|', 2)
257+
258+
# Support Git 1.x which does not have `%(refname:lstrip=2)`.
259+
tag = str('/').join(rawtag.split('/')[:2])
260+
257261
if not tag.startswith('r'):
258262
continue # We only care about "rX.Y.Z" release tags.
259263
if re.match(r'r\d+\.\d+', tag):

0 commit comments

Comments
 (0)