RuntimeError if submodule has no branch
未关闭
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1.7k
- 派生
- 408
- 平均合并
- 2 天 57 分钟
- 30 天内合并 PR
- 7
描述
If a submodule has been added without the --branch option, accessing the Submodule.branch property raises a RuntimeError:
❯❯❯ git init
Initialized empty Git repository in /tmp/gregoire/tmp.R3p5f9ZTwD/.git/
❯❯❯ git submodule add https://github.com/libgit2/pygit2.git pygit2 --branch=master
[...]
❯❯❯ python3 -c 'import pygit2; print(pygit2.Repository(".").lookup_submodule("pygit2").branch)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/gregoire/.local/lib/python3.7/site-packages/pygit2/submodule.py", line 80, in branch
return ffi.string(branch).decode('utf-8')
RuntimeError: cannot use string() on <cdata 'char *' NULL>
It works fine if --branch is added to git submodule add:
❯❯❯ git init
Initialized empty Git repository in /tmp/gregoire/tmp.R3p5f9ZTwD/.git/
❯❯❯ git submodule add https://github.com/libgit2/pygit2.git pygit2
[...]
❯❯❯ python3 -c 'import pygit2; print(pygit2.Repository(".").lookup_submodule("pygit2").branch)'
master
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 pygit2/submodule.py 中的 Submodule.branch 属性开始,该属性对应于报告中显示的出错行,并使用在未指定 --branch 的情况下添加的子模块重现该问题。为该情况添加回归测试覆盖,并验证访问 branch 不再引发 NULL cdata RuntimeError,同时符合预期的 API 行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- git, python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100