Repository.resolve_refish can return a Tag, violates docstring and typehint
未关闭
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1.7k
- 派生
- 408
- 平均合并
- 2 天 57 分钟
- 30 天内合并 PR
- 7
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Repository.resolve_refish 入口开始,检查符号引用和直接对象 ID 的解析方式。查找涵盖 Commit、Tag 和 ref 目标的现有测试,然后与维护者确认预期的返回契约。只有在文档和类型定义中的行为与已验证的行为一致,并且两个示例都有回归测试覆盖时,才算完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- git, python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100