File tree 5 files changed +26
-10
lines changed
5 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -721,7 +721,8 @@ public void CanGeneratePredictableObjectShas()
721
721
Tree tree = commit . Tree ;
722
722
Assert . Equal ( "2b297e643c551e76cfa1f93810c50811382f9117" , tree . Sha ) ;
723
723
724
- Blob blob = tree . Blobs . Single ( ) ;
724
+ GitObject blob = tree . Single ( ) . Target ;
725
+ Assert . IsAssignableFrom < Blob > ( blob ) ;
725
726
Assert . Equal ( "9daeafb9864cf43055ae93beb0afd6c7d144bfa4" , blob . Sha ) ;
726
727
}
727
728
}
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public void ComparingABlobAgainstItselfReturnsNoDifference()
13
13
{
14
14
using ( var repo = new Repository ( StandardTestRepoPath ) )
15
15
{
16
- Blob blob = repo . Head . Tip . Tree . Blobs . First ( ) ;
16
+ var blob = repo . Lookup < Blob > ( "7909961" ) ;
17
17
18
18
ContentChanges changes = repo . Diff . Compare ( blob , blob ) ;
19
19
@@ -78,7 +78,7 @@ public void CanCompareATextualBlobAgainstABinaryBlob()
78
78
{
79
79
Blob binBlob = CreateBinaryBlob ( repo ) ;
80
80
81
- Blob blob = repo . Head . Tip . Tree . Blobs . First ( ) ;
81
+ var blob = repo . Lookup < Blob > ( "7909961" ) ;
82
82
83
83
ContentChanges changes = repo . Diff . Compare ( blob , binBlob ) ;
84
84
@@ -94,7 +94,7 @@ public void CanCompareABlobAgainstANullBlob()
94
94
{
95
95
using ( var repo = new Repository ( StandardTestRepoPath ) )
96
96
{
97
- Blob blob = repo . Head . Tip . Tree . Blobs . First ( ) ;
97
+ var blob = repo . Lookup < Blob > ( "7909961" ) ;
98
98
99
99
ContentChanges changes = repo . Diff . Compare ( null , blob ) ;
100
100
Original file line number Diff line number Diff line change @@ -356,8 +356,7 @@ public void CanAddATagPointingToABlob()
356
356
string path = CloneBareTestRepo ( ) ;
357
357
using ( var repo = new Repository ( path ) )
358
358
{
359
- Commit headCommit = repo . Head . Tip ;
360
- Blob blob = headCommit . Tree . Blobs . First ( ) ;
359
+ var blob = repo . Lookup < Blob > ( "a823312" ) ;
361
360
362
361
Tag tag = repo . ApplyTag ( "blob-tag" , blob . Sha ) ;
363
362
Assert . NotNull ( tag ) ;
Original file line number Diff line number Diff line change 1
- using System . IO ;
1
+ using System . Collections . Generic ;
2
+ using System . IO ;
2
3
using System . Linq ;
3
4
using LibGit2Sharp . Tests . TestHelpers ;
4
5
using Xunit ;
@@ -54,7 +55,13 @@ public void CanEnumerateBlobs()
54
55
using ( var repo = new Repository ( BareTestRepoPath ) )
55
56
{
56
57
var tree = repo . Lookup < Tree > ( sha ) ;
57
- Assert . Equal ( 3 , tree . Blobs . Count ( ) ) ;
58
+
59
+ IEnumerable < Blob > blobs = tree
60
+ . Where ( e => e . TargetType == TreeEntryTargetType . Blob )
61
+ . Select ( e => e . Target )
62
+ . Cast < Blob > ( ) ;
63
+
64
+ Assert . Equal ( 3 , blobs . Count ( ) ) ;
58
65
}
59
66
}
60
67
@@ -64,7 +71,13 @@ public void CanEnumerateSubTrees()
64
71
using ( var repo = new Repository ( BareTestRepoPath ) )
65
72
{
66
73
var tree = repo . Lookup < Tree > ( sha ) ;
67
- Assert . Equal ( 1 , tree . Trees . Count ( ) ) ;
74
+
75
+ IEnumerable < Tree > subTrees = tree
76
+ . Where ( e => e . TargetType == TreeEntryTargetType . Tree )
77
+ . Select ( e => e . Target )
78
+ . Cast < Tree > ( ) ;
79
+
80
+ Assert . Equal ( 1 , subTrees . Count ( ) ) ;
68
81
}
69
82
}
70
83
Original file line number Diff line number Diff line change 1
- using System . Collections ;
1
+ using System ;
2
+ using System . Collections ;
2
3
using System . Collections . Generic ;
3
4
using System . Diagnostics ;
4
5
using System . Globalization ;
@@ -71,6 +72,7 @@ private TreeEntry RetrieveFromPath(FilePath relativePath)
71
72
/// <summary>
72
73
/// Gets the <see cref = "Tree" />s immediately under this <see cref = "Tree" />.
73
74
/// </summary>
75
+ [ Obsolete ( "This property will be removed in the next release." ) ]
74
76
public virtual IEnumerable < Tree > Trees
75
77
{
76
78
get
@@ -85,6 +87,7 @@ public virtual IEnumerable<Tree> Trees
85
87
/// <summary>
86
88
/// Gets the <see cref = "Blob" />s immediately under this <see cref = "Tree" />.
87
89
/// </summary>
90
+ [ Obsolete ( "This property will be removed in the next release." ) ]
88
91
public virtual IEnumerable < Blob > Blobs
89
92
{
90
93
get
You can’t perform that action at this time.
0 commit comments