Skip to content

Commit a9022f0

Browse files
authored
Fix detection of annotated git tags (#74)
This commit extends vcs2l's tag detection scheme to support annotated tags, building on the existing support for lightweight tags. The new detection logic adds awareness of some git plumbing details regarding how the tag's message is stored in relation to the SHA it references. I updated the test to use an annotated tag for one of the tags in the list to exercise this feature. Signed-off-by: Scott K Logan <[email protected]>
1 parent 374e480 commit a9022f0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def setUpClass(cls):
6363
('branch', '--quiet', '-D', 'license'),
6464
('commit', '--quiet', '--allow-empty', '-m', 'update changelog'),
6565
('commit', '--quiet', '--allow-empty', '-m', '0.1.27'),
66-
('tag', '0.1.27'),
66+
('tag', '0.1.27', '-m', '0.1.27'),
6767
('commit', '--quiet', '--allow-empty', '-m', "codin' codin' codin'"),
6868
):
6969
subprocess.check_call(

vcs2l/clients/git.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def export(self, command):
188188
'ls-remote',
189189
remote,
190190
'refs/tags/' + tag,
191+
'refs/tags/' + tag + '^{}',
191192
]
192193
result_ls_remote = self._run_command(cmd_ls_remote)
193194
if result_ls_remote['returncode']:
@@ -197,8 +198,10 @@ def export(self, command):
197198
)
198199
return result_ls_remote
199200
matches = self._get_hash_ref_tuples(result_ls_remote['output'])
200-
if len(matches) == 1 and matches[0][0] == ref:
201-
ref = tag
201+
for match_hash, _ in matches:
202+
if match_hash == ref:
203+
ref = tag
204+
break
202205

203206
# determine url of remote
204207
result_url = self._get_remote_url(remote)

0 commit comments

Comments
 (0)