libgit2 / libgit2/pygit2

Git submodule fials if branch not present

オープン
#1,361 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
1.7k
フォーク
408
平均マージ
2日 57分
マージ済み PR(30日)
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')

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

pygit2/submodules.py の Submodule.branch プロパティから始め、C.git_submodule_branch が未設定のブランチをどのように返すかを調べます。ブランチが設定されていないサブモジュールでの動作を確認し、プロパティにアクセスしても報告されている NULL cdata RuntimeError が発生しなくなっていることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
git, python
領域
devtools
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
58/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。