We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 340044b + e4f1aa7 commit 333786cCopy full SHA for 333786c
2 files changed
git/repo/fun.py
@@ -301,7 +301,13 @@ def rev_parse(repo: "Repo", rev: str) -> AnyGitObject:
301
302
# Handle type.
303
if output_type == "commit":
304
- pass # Default.
+ obj = cast("TagObject", obj)
305
+ if obj and obj.type == "tag":
306
+ obj = deref_tag(obj)
307
+ else:
308
+ # Cannot do anything for non-tags.
309
+ pass
310
+ # END handle tag
311
elif output_type == "tree":
312
try:
313
obj = cast(AnyGitObject, obj)
test/test_repo.py
@@ -1064,9 +1064,9 @@ def test_rev_parse(self):
1064
# TODO: Dereference tag into a blob 0.1.7^{blob} - quite a special one.
1065
# Needs a tag which points to a blob.
1066
1067
- # ref^0 returns commit being pointed to, same with ref~0, and ^{}
+ # ref^0 returns commit being pointed to, same with ref~0, ^{}, and ^{commit}
1068
tag = rev_parse("0.1.4")
1069
- for token in ("~0", "^0", "^{}"):
+ for token in ("~0", "^0", "^{}", "^{commit}"):
1070
self.assertEqual(tag.object, rev_parse("0.1.4%s" % token))
1071
# END handle multiple tokens
1072
0 commit comments