1
1
using System ;
2
+ using System . IO ;
2
3
using System . Linq ;
3
4
using LibGit2Sharp . Tests . TestHelpers ;
4
5
using Xunit ;
@@ -103,14 +104,17 @@ public void CanEnumerateRepositorySubmodules()
103
104
}
104
105
105
106
[ Theory ]
106
- [ InlineData ( "sm_changed_head" ) ]
107
- [ InlineData ( "sm_changed_head/" ) ]
108
- public void CanStageChangeInSubmoduleViaIndexStage ( string submodulePath )
107
+ [ InlineData ( "sm_changed_head" , false ) ]
108
+ [ InlineData ( "sm_changed_head" , true ) ]
109
+ public void CanStageChangeInSubmoduleViaIndexStage ( string submodulePath , bool appendPathSeparator )
109
110
{
111
+ submodulePath += appendPathSeparator ? Path . DirectorySeparatorChar : default ( char ? ) ;
112
+
110
113
var path = CloneSubmoduleTestRepo ( ) ;
111
114
using ( var repo = new Repository ( path ) )
112
115
{
113
116
var submodule = repo . Submodules [ submodulePath ] ;
117
+ Assert . NotNull ( submodule ) ;
114
118
115
119
var statusBefore = submodule . RetrieveStatus ( ) ;
116
120
Assert . Equal ( SubmoduleStatus . WorkDirModified , statusBefore & SubmoduleStatus . WorkDirModified ) ;
@@ -123,21 +127,24 @@ public void CanStageChangeInSubmoduleViaIndexStage(string submodulePath)
123
127
}
124
128
125
129
[ Theory ]
126
- [ InlineData ( "sm_changed_head" ) ]
127
- [ InlineData ( "sm_changed_head/" ) ]
128
- public void CanStageChangeInSubmoduleViaIndexStageWithOtherPaths ( string submodulePath )
130
+ [ InlineData ( "sm_changed_head" , false ) ]
131
+ [ InlineData ( "sm_changed_head" , true ) ]
132
+ public void CanStageChangeInSubmoduleViaIndexStageWithOtherPaths ( string submodulePath , bool appendPathSeparator )
129
133
{
134
+ submodulePath += appendPathSeparator ? Path . DirectorySeparatorChar : default ( char ? ) ;
135
+
130
136
var path = CloneSubmoduleTestRepo ( ) ;
131
137
using ( var repo = new Repository ( path ) )
132
138
{
133
139
var submodule = repo . Submodules [ submodulePath ] ;
140
+ Assert . NotNull ( submodule ) ;
134
141
135
142
var statusBefore = submodule . RetrieveStatus ( ) ;
136
143
Assert . Equal ( SubmoduleStatus . WorkDirModified , statusBefore & SubmoduleStatus . WorkDirModified ) ;
137
144
138
145
Touch ( repo . Info . WorkingDirectory , "new-file.txt" ) ;
139
146
140
- repo . Index . Stage ( new [ ] { "new-file.txt" , submodulePath , "does-not-exist.txt" } ) ;
147
+ repo . Index . Stage ( new [ ] { "new-file.txt" , submodulePath , "does-not-exist.txt" } ) ;
141
148
142
149
var statusAfter = submodule . RetrieveStatus ( ) ;
143
150
Assert . Equal ( SubmoduleStatus . IndexModified , statusAfter & SubmoduleStatus . IndexModified ) ;
0 commit comments