Repository.create_note() does not accept bytes
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 1.7k
- フォーク
- 408
- 平均マージ
- 2日 57分
- マージ済み PR(30日)
- 7
説明
Hi,
Thank you for pygit2! I'm using it heavily in a project to present all Ubuntu source package history as git repositories.
Any chance Repository.create_note() could be adjusted to accept bytes as well as str? An issue I just hit is when I'm trying to create git notes that contain text that is not UTF-8 encoded. This happened historically in Debian/Ubuntu packaging history and I'd like to represent that in git notes that get created by just "passing through" the unknown encoding. As git doesn't care about the encoding of a note, I think this should work OK.
The relevant code is here: https://github.com/libgit2/pygit2/blob/58da6bb2b958139dab285e183ca6616509960587/src/repository.c#L1677
It looks like this could just be tweaked slightly to also accept a bytes, as it's all being converted into a C-string to hand to git anyway. There might be an edge case to consider when the bytes contains NULs. That might have to be unacceptable, tested for and result in a ValueError. It might also make sense to adjust behaviour everywhere pygit2 accepts a string to hand to git, so I appreciate it's a bit of a rabbit hole.
This isn't essential so I can work around this and don't want to get into testing a patch right now, but I thought it might be worth noting this in your issue tracker (and I can now link to this from my workaround).
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/repository.c の 1677 行目付近にある Repository.create_note() から始め、Git に渡される前にノートメッセージがどのように変換されるかを調べます。UTF-8 ではないノート内容について str とともに bytes も受け入れ、埋め込まれた NUL バイトに対して、ValueError で拒否するなどの定義済みの結果が得られれば作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- git, python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100