Git submodule fials if branch not present
未关闭
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1.7k
- 派生
- 408
- 平均合并
- 2 天 57 分钟
- 30 天内合并 PR
- 7
描述
In case if I want to check if branch was provided to submodule and it is not provided I got error
if sm.branch:
name = f"{sm.branch}/{sm.name}"
else:
name = f"{sm.name}"
File "/app/venv/lib/python3.11/site-packages/pygit2/submodules.py", line 148, in branch return ffi.string(branch).decode('utf-8') ^^^^^^^^^^^^^^^^^^ RuntimeError: cannot use string() on <cdata 'char *' NULL>
It looks like there is missing check if branch is actually set
class Submodule:
...
@property
def branch(self):
"""Branch that is to be tracked by the submodule."""
branch = C.git_submodule_branch(self._subm)
return ffi.string(branch).decode('utf-8')
I think it should be like this
@property
def branch(self):
"""Branch that is to be tracked by the submodule."""
branch = C.git_submodule_branch(self._subm)
if branch:
return ffi.string(branch).decode('utf-8')
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 pygit2/submodules.py 中的 Submodule.branch 属性开始,检查 C.git_submodule_branch 如何返回未设置的分支。验证没有配置分支的子模块的行为,并确认访问该属性不再引发报告中的 NULL cdata RuntimeError。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- git, python
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 58/100