10000 Deprecate Blob.Content · philhack/libgit2sharp@71090d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 71090d3

Browse files
Aimeastnulltoken
authored andcommitted
Deprecate Blob.Content
1 parent 2e201d5 commit 71090d3

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

LibGit2Sharp.Tests/BlobFixture.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect
6868
var commit = repo.Commit("bom", Constants.Signature, Constants.Signature);
6969

7070
var blob = (Blob)commit.Tree[bomFile].Target;
71-
Assert.Equal(expectedContentBytes, blob.Content.Length);
71+
Assert.Equal(expectedContentBytes, blob.GetContentStream().Length);
7272

7373
var textDetected = blob.GetContentText();
7474
Assert.Equal(content, textDetected);
@@ -101,20 +101,6 @@ public void CanLookUpBlob()
101101
}
102102
}
103103

104-
[Fact]
105-
public void CanReadBlobContent()
106-
{
107-
using (var repo = new Repository(BareTestRepoPath))
108-
{
109-
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
110-
byte[] bytes = blob.Content;
111-
Assert.Equal(10, bytes.Length);
112-
113-
string content = Encoding.UTF8.GetString(bytes);
114-
Assert.Equal("hey there\n", content);
115-
}
116-
}
117-
118104
[Fact]
119105
public void CanReadBlobStream()
120106
{

LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny()
466466
// Recreate the file in the workdir without the executable bit
467467
string fullpath = Path.Combine(repo.Info.WorkingDirectory, file);
468468
File.Delete(fullpath);
469-
File.WriteAllBytes(fullpath, ((Blob)(entry.Target)).Content);
469+
using (var stream = ((Blob)(entry.Target)).GetContentStream())
470+
{
471+
Touch(repo.Info.WorkingDirectory, file, stream);
472+
}
470473

471474
// Unset the local core.filemode, if any.
472475
repo.Config.Unset("core.filemode");

LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny()
114114
// Recreate the file in the workdir without the executable bit
115115
string fullpath = Path.Combine(repo.Info.WorkingDirectory, file);
116116
File.Delete(fullpath);
117-
File.WriteAllBytes(fullpath, ((Blob)(entry.Target)).Content);
117+
using (var stream = ((Blob)(entry.Target)).GetContentStream())
118+
{
119+
Touch(repo.Info.WorkingDirectory, file, stream);
120+
}
118121

119122
// Unset the local core.filemode, if any.
120123
repo.Config.Unset("core.filemode", ConfigurationLevel.Local);

LibGit2Sharp/Blob.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ internal Blob(Repository repo, ObjectId id)
3838
/// <summary>
3939
/// Gets the blob content in a <see cref="byte"/> array.
4040
/// </summary>
41+
[Obsolete("This property will be removed in the next release. Please use one of the GetContentStream() overloads instead.")]
4142
public virtual byte[] Content
4243
{
4344
get

0 commit comments

Comments
 (0)
0