File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 1
- using System . IO ;
1
+ using System ;
2
+ using System . IO ;
2
3
using System . Linq ;
3
4
using LibGit2Sharp . Tests . TestHelpers ;
4
5
using NUnit . Framework ;
@@ -125,5 +126,27 @@ public void RetrievingTheStatusOfARepositoryReturnNativeFilePaths()
125
126
repoStatus . Added . Single ( ) . ShouldEqual ( statusEntry . FilePath ) ;
126
127
}
127
128
}
129
+
130
+ [ Test ]
131
+ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives ( )
132
+ {
133
+ TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo ( StandardTestRepoWorkingDirPath ) ;
134
+ using ( var repo = new Repository ( path . RepositoryPath ) )
135
+ {
136
+ string relativePath = Path . Combine ( "1" , "look-ma.txt" ) ;
137
+ string fullFilePath = Path . Combine ( repo . Info . WorkingDirectory , relativePath ) ;
138
+ File . WriteAllText ( fullFilePath , "I'm going to be ignored!" ) ;
139
+
140
+ RepositoryStatus status = repo . Index . RetrieveStatus ( ) ;
141
+
142
+ CollectionAssert . AreEqual ( new [ ] { relativePath , "new_untracked_file.txt" } , status . Untracked ) ;
143
+
144
+ string gitignorePath = Path . Combine ( repo . Info . WorkingDirectory , ".gitignore" ) ;
145
+ File . WriteAllText ( gitignorePath , "*.txt" + Environment . NewLine ) ;
146
+
147
+ RepositoryStatus newStatus = repo . Index . RetrieveStatus ( ) ;
148
+ newStatus . Untracked . Single ( ) . ShouldEqual ( ".gitignore" ) ;
149
+ }
150
+ }
128
151
}
129
152
}
You can’t perform that action at this time.
0 commit comments