libgit2 / libgit2/pygit2

checking to see if diffFile is a submodule.

未关闭
#838 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
1.7k
派生
408
平均合并
2 天 57 分钟
30 天内合并 PR
7

描述

Is there a way to check to see if a diffFile is a submodule?

The repo that I'm getting my diff deltas from is bare so there's no working directory for Repository.lookup_submodule(path) or Repository.listall_submodules() to work with.

The main issue is when I try to get an added file via something like:

new_file = git_repo[delta.new_file.id]

I get the following key error.

Traceback (most recent call last):
  File "/Users/user/project/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/user/project/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/user/project/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/user/project/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/user/project/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/Users/user/project/repos/views.py", line 105, in get
    new_file = git_repo[delta.new_file.id]
  File "/Users/user/project/venv/lib/python3.7/site-packages/pygit2/repository.py", line 121, in __getitem__
    raise KeyError(key)
KeyError: ffeef8955335d0ec95f23c2fd75821672cf14bb9

If it's a submodule I don't need the contents. I just need to know that it's a submodule. Is there a general way to do this?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先阅读围绕 delta.new_file.id 的处理,以及 Repository.lookup_submodule(path) 和 Repository.listall_submodules() API,尤其要关注 bare repositories。检查 diff 条目如何在不加载其内容的情况下识别子模块。在对仓库建立索引之前,能够通过文档说明或提供一种可靠的方法来区分子模块条目,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
git, python
领域
devtools
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。