Feature request: Create blobs in-memory
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu bằng cách lần theo quá trình xây dựng Blob, ObjectDatabase.Write và Diff.Compare trong API libgit2sharp. Hành vi được yêu cầu là tạo các blob từ chuỗi hoặc stream và truyền chúng cho các diff trong bộ nhớ mà không ghi ra đĩa hoặc yêu cầu một repository dựa trên đĩa; hãy xác thực điều này bằng nội dung cũ và mới được hiển thị trong issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C#
- Star
- 3.5k
- Fork
- 925
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của libgit2/libgit2sharp
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
libgit2/libgit2sharp#2193 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
libgit2/libgit2sharp#2192 · 1 bình luận ·
-
Website is down Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
libgit2/libgit2sharp#2191 · 2 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
libgit2/libgit2sharp#2189 · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
libgit2/libgit2sharp#2187 · 2 bình luận ·
Tất cả issue của libgit2/libgit2sharp
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
azurenoops/spin_agent#975 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SubtitleEdit/subtitleedit#15108 · 1 bình luận ·