libgit2 / libgit2/libgit2sharp
Feature request: Create blobs in-memory
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 3.5k
- フォーク
- 925
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I would like to make a diff between two strings with libgit2sharp. The strings hold file contents loaded elsewhere. The diff.Compare-methods only take blobs, and the constructors of the Blobclass don't accept strings or streams and are marked internal. This prevents me from creating blobs directly. I have to write to disk first.
var oldFileContents = @"
Line 1
Line 2
Line 3
";
var newFileContents = @"
Line 1
Line 2 has changed
";
var path = Repository.Init("C:\\tmp");
var repo = new Repository(path);
var oldObjectId = repo.ObjectDatabase.Write<Blob>(Encoding.UTF8.GetBytes(oldFileContents));
var newObjectId = repo.ObjectDatabase.Write<Blob>(Encoding.UTF8.GetBytes(newFileContents));
var oldBlob = repo.Lookup<Blob>(oldObjectId);
var newBlob = repo.Lookup<Blob>(newObjectId);
var diff = repo.Diff.Compare(oldBlob, newBlob); // Works as expected
// git repo for in-memory operations
var in_memory_repo = new Repository();
// This line failes with the LibGit2SharpException "path cannot exist in repository". As far as I can see this is intentional.
var in_memory_blob = in_memory_repo.ObjectDatabase.Write<Blob>(Encoding.UTF8.GetBytes(oldFileContents));
Seeing that libgit2sharp already supports working with diffs and patches in-memory, it would be nice to be able to create blobs from strings or streams.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、libgit2sharp API における Blob の構築、ObjectDatabase.Write、および Diff.Compare を追跡します。要求されている動作は、文字列またはストリームから blob を作成し、ディスクに書き込んだりディスクベースのリポジトリを必要としたりせずに、それらをインメモリ diff に渡すことです。Issue に示されている古い内容と新しい内容を使ってこれを検証してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, git
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100