- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 402
 
Open
Description
The typing hint and docstring of Repository.resolve_refish says it returns a Commit object. Actually, it will return a Tag object if given a tag's hex oid. Is this the expected behavior.
For example, in the Linux kernel:
assert pygit2.__version__ == "1.18.0"
# OID of `v6.12.1^{tag}` and v6.12.1^{commit}` in Linux kernel.                 
tag_oid = Oid(hex="a554dea023a451ad985c071f8aae6415f0e274df")   
commit_oid = Oid(hex="d390303b28dabbb91b2d32016a4f72da478733b9")
                                                                
# As documented, symbolic refs resolve to a commit object.
# But the ref target differs from the returned object. Is this the desired behavior?
obj, ref = repo.resolve_refish("v6.12.1")             
assert isinstance(obj, Commit)                                  
assert ref.target != obj.id
assert ref.target == tag_oid                               
# Contrary to the docstring and typing hint, this returns a Tag object.                                                                
obj, ref = repo.resolve_refish(str(tag_oid))                    
assert isinstance(obj, Tag)                                     
assert ref is None
Metadata
Metadata
Assignees
Labels
No labels