diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-05-09 14:03:57 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-05-15 21:31:44 +0400 |
commit | ac34838024045b43cccb060dbf05544fbf008fbc (patch) | |
tree | b087c09afc55efa4bd42317827c6b5a41238d63d | |
parent | 2b77adbf4e5bb185160625ca0e2f71f3187f4b52 (diff) |
Add some .gitignore handling test coverage
-rw-r--r-- | LibGit2Sharp.Tests/StatusFixture.cs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/StatusFixture.cs b/LibGit2Sharp.Tests/StatusFixture.cs index dd065c94..f2194ee2 100644 --- a/LibGit2Sharp.Tests/StatusFixture.cs +++ b/LibGit2Sharp.Tests/StatusFixture.cs @@ -128,6 +128,31 @@ namespace LibGit2Sharp.Tests } [Fact] + public void RetrievingTheStatusOfAnEmptyRepositoryHonorsTheGitIgnoreDirectives() + { + SelfCleaningDirectory scd = BuildSelfCleaningDirectory(); + + using (Repository repo = Repository.Init(scd.DirectoryPath)) + { + string relativePath = "look-ma.txt"; + string fullFilePath = Path.Combine(repo.Info.WorkingDirectory, relativePath); + File.WriteAllText(fullFilePath, "I'm going to be ignored!"); + + RepositoryStatus status = repo.Index.RetrieveStatus(); + Assert.Equal(new[] { relativePath }, status.Untracked); + + string gitignorePath = Path.Combine(repo.Info.WorkingDirectory, ".gitignore"); + File.WriteAllText(gitignorePath, "*.txt" + Environment.NewLine); + + RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + newStatus.Untracked.Single().ShouldEqual(".gitignore"); + + repo.Index.RetrieveStatus(relativePath).ShouldEqual(FileStatus.Ignored); + Assert.Equal(new[] { relativePath }, newStatus.Ignored); + } + } + + [Fact] public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives() { TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath); @@ -137,6 +162,37 @@ namespace LibGit2Sharp.Tests string fullFilePath = Path.Combine(repo.Info.WorkingDirectory, relativePath); File.WriteAllText(fullFilePath, "I'm going to be ignored!"); + /* + * $ git status --ignored + * # On branch master + * # Your branch and 'origin/master' have diverged, + * # and have 2 and 2 different commit(s) each, respectively. + * # + * # Changes to be committed: + * # (use "git reset HEAD <file>..." to unstage) + * # + * # deleted: deleted_staged_file.txt + * # modified: modified_staged_file.txt + * # new file: new_tracked_file.txt + * # + * # Changes not staged for commit: + * # (use "git add/rm <file>..." to update what will be committed) + * # (use "git checkout -- <file>..." to discard changes in working directory) + * # + * # modified: 1/branch_file.txt + * # modified: README + * # modified: branch_file.txt + * # deleted: deleted_unstaged_file.txt + * # modified: modified_unstaged_file.txt + * # modified: new.txt + * # + * # Untracked files: + * # (use "git add <file>..." to include in what will be committed) + * # + * # 1/look-ma.txt + * # new_untracked_file.txt + */ + RepositoryStatus status = repo.Index.RetrieveStatus(); Assert.Equal(new[]{relativePath, "new_untracked_file.txt"}, status.Untracked); @@ -144,6 +200,41 @@ namespace LibGit2Sharp.Tests string gitignorePath = Path.Combine(repo.Info.WorkingDirectory, ".gitignore"); File.WriteAllText(gitignorePath, "*.txt" + Environment.NewLine); + /* + * $ git status --ignored + * # On branch master + * # Your branch and 'origin/master' have diverged, + * # and have 2 and 2 different commit(s) each, respectively. + * # + * # Changes to be committed: + * # (use "git reset HEAD <file>..." to unstage) + * # + * # deleted: deleted_staged_file.txt + * # modified: modified_staged_file.txt + * # new file: new_tracked_file.txt + * # + * # Changes not staged for commit: + * # (use "git add/rm <file>..." to update what will be committed) + * # (use "git checkout -- <file>..." to discard changes in working directory) + * # + * # modified: 1/branch_file.txt + * # modified: README + * # modified: branch_file.txt + * # deleted: deleted_unstaged_file.txt + * # modified: modified_unstaged_file.txt + * # modified: new.txt + * # + * # Untracked files: + * # (use "git add <file>..." to include in what will be committed) + * # + * # .gitignore + * # Ignored files: + * # (use "git add -f <file>..." to include in what will be committed) + * # + * # 1/look-ma.txt + * # new_untracked_file.txt + */ + RepositoryStatus newStatus = repo.Index.RetrieveStatus(); newStatus.Untracked.Single().ShouldEqual(".gitignore"); |