libgit2 / libgit2/pygit2

update_submodules duplicates

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

还没有人认领这个 Issue。

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

描述

I'm trying to replicate git clone --recursive in pygit2, and this is the function I've come up with.

def get_submodules(repo, creds):
    submodules = repo.listall_submodules()
    repo.init_submodules(submodules=submodules)
    repo.update_submodules(submodules=submodules, callbacks=creds)
    for submodule_path in submodules:
        submodule = repo.lookup_submodule(submodule_path)
        sub_repo = submodule.open()
        get_submodules(sub_repo, creds)

The problem I'm having is that in certain circumstances, this will cause crashes. Let me paint the picture.

Master Repo

  1. Submodule A
  2. Submodule B
    2.1 Submodule A
    2.2 Submodule D
  3. Submodule C

When update_submodules attempts to run on Submodule A the second time, it crashes. Not completely sure how to get around this. Some repos are in this format, but I haven't found a workaround. Any thoughts?

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 get_submodules 示例以及 repo.update_submodules 和 repo.lookup_submodule 调用开始。重现 Submodule A 出现多次的嵌套布局,然后检查重复更新是如何处理的。当递归操作在该布局下不再崩溃,并且已根据所报告的场景验证行为时,即表示完成。

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

评估

技术栈
git, python
领域
tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
32/100

把新 issue 发到你的邮箱

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