From de4d5e5e4c551338e237d4587008abf3650903ae Mon Sep 17 00:00:00 2001 From: Orn Kristjansson Date: Tue, 15 Nov 2016 16:02:09 -0700 Subject: [PATCH 1/6] Test to show forward and backslashes in sub directories are handled correctly. Ref https://github.com/libgit2/libgit2sharp/issues/1075 --- LibGit2Sharp.Tests/FileHistoryFixture.cs | 33 ++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/LibGit2Sharp.Tests/FileHistoryFixture.cs b/LibGit2Sharp.Tests/FileHistoryFixture.cs index c74165fcf..4a4148738 100644 --- a/LibGit2Sharp.Tests/FileHistoryFixture.cs +++ b/LibGit2Sharp.Tests/FileHistoryFixture.cs @@ -290,9 +290,38 @@ public void UnsupportedSortStrategyThrows() } } - #region Helpers + [Theory] + [InlineData("https://github.com/ornatwork/nugetpackages")] + public void HandlesSubDirectorySeperators(string url) + { + var scd = BuildSelfCleaningDirectory(); + var clonedRepoPath = Repository.Clone(url, scd.DirectoryPath); + string subdir1 = "devbox"; + string subdir2_double_backslash = subdir1 + Path.DirectorySeparatorChar + "content"; + string subdir2_forwardslash = subdir1 + Path.AltDirectorySeparatorChar + "content"; + + // Check + using (var repo = new Repository(clonedRepoPath)) + { + // Total commits for repo + Assert.True( repo.Commits.Count() > 7 ); + // Subdir1 + IEnumerable history1 = repo.Commits.QueryBy(subdir1); + Assert.True(history1.Count() > 1); + + // subdir2 using double backslash + IEnumerable history1_1 = repo.Commits.QueryBy(subdir2_double_backslash); + Assert.True(history1_1.Count() > 0); + + // subdir2 using forward slash + IEnumerable history2_1 = repo.Commits.QueryBy(subdir2_forwardslash); + Assert.True(history2_1.Count() > 0); + } + } + + #region Helpers - private Signature _signature = Constants.Signature; + private Signature _signature = Constants.Signature; private const string SubFolderPath1 = "SubFolder1"; private Signature GetNextSignature() From f106092db40448a4488cec4afaf53813904d62f2 Mon Sep 17 00:00:00 2001 From: Orn Kristjansson Date: Fri, 18 Nov 2016 16:45:10 -0700 Subject: [PATCH 2/6] Removed HandlesSubDirectorySeperators test --- LibGit2Sharp.Tests/FileHistoryFixture.cs | 29 ------------------------ 1 file changed, 29 deletions(-) diff --git a/LibGit2Sharp.Tests/FileHistoryFixture.cs b/LibGit2Sharp.Tests/FileHistoryFixture.cs index 4a4148738..d031f810b 100644 --- a/LibGit2Sharp.Tests/FileHistoryFixture.cs +++ b/LibGit2Sharp.Tests/FileHistoryFixture.cs @@ -290,35 +290,6 @@ public void UnsupportedSortStrategyThrows() } } - [Theory] - [InlineData("https://github.com/ornatwork/nugetpackages")] - public void HandlesSubDirectorySeperators(string url) - { - var scd = BuildSelfCleaningDirectory(); - var clonedRepoPath = Repository.Clone(url, scd.DirectoryPath); - string subdir1 = "devbox"; - string subdir2_double_backslash = subdir1 + Path.DirectorySeparatorChar + "content"; - string subdir2_forwardslash = subdir1 + Path.AltDirectorySeparatorChar + "content"; - - // Check - using (var repo = new Repository(clonedRepoPath)) - { - // Total commits for repo - Assert.True( repo.Commits.Count() > 7 ); - // Subdir1 - IEnumerable history1 = repo.Commits.QueryBy(subdir1); - Assert.True(history1.Count() > 1); - - // subdir2 using double backslash - IEnumerable history1_1 = repo.Commits.QueryBy(subdir2_double_backslash); - Assert.True(history1_1.Count() > 0); - - // subdir2 using forward slash - IEnumerable history2_1 = repo.Commits.QueryBy(subdir2_forwardslash); - Assert.True(history2_1.Count() > 0); - } - } - #region Helpers private Signature _signature = Constants.Signature; From 8c9791b6a0df6224af4d8473b7903dd74466882a Mon Sep 17 00:00:00 2001 From: Orn Kristjansson Date: Fri, 18 Nov 2016 17:42:29 -0700 Subject: [PATCH 3/6] Beefed PatchEntryChanges coverage to 100% --- LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj | 1 + .../PatchEntryChangesFixture.cs | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 LibGit2Sharp.Tests/PatchEntryChangesFixture.cs diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj index 0be3440c6..24abbb804 100644 --- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj +++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj @@ -65,6 +65,7 @@ + diff --git a/LibGit2Sharp.Tests/PatchEntryChangesFixture.cs b/LibGit2Sharp.Tests/PatchEntryChangesFixture.cs new file mode 100644 index 000000000..2d5c1030a --- /dev/null +++ b/LibGit2Sharp.Tests/PatchEntryChangesFixture.cs @@ -0,0 +1,47 @@ +using System; +using System.IO; +using System.Linq; +using System.Text; +using LibGit2Sharp.Tests.TestHelpers; +using Xunit; +using Xunit.Extensions; + + +namespace LibGit2Sharp.Tests +{ + public class PatchEntryChangesFixture : BaseFixture + { + + [Fact] + public void PatchEntryBasics() + { + // Init test repo + var path = SandboxStandardTestRepoGitDir(); + string file = "numbers.txt"; + + // The repo + using (var repo = new Repository(path)) + { + Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; + Tree commitTreeWithUpdatedFile = repo.Lookup("ec9e401").Tree; + + // Create path by diffing + using (var patch = repo.Diff.Compare(rootCommitTree, commitTreeWithUpdatedFile)) + { + PatchEntryChanges entryChanges = patch[file]; + Assert.Equal(2, entryChanges.LinesAdded); + Assert.Equal(1, entryChanges.LinesDeleted); + Assert.Equal(187, entryChanges.Patch.Length); + // Smoke test + Assert.Equal(Mode.NonExecutableFile, entryChanges.Mode); + Assert.Equal(new ObjectId("4625a3628cb78970c57e23a2fe2574514ba403c7"), entryChanges.Oid); + Assert.Equal(ChangeKind.Modified, entryChanges.Status); + Assert.Equal(file, entryChanges.OldPath); + Assert.Equal(Mode.NonExecutableFile, entryChanges.OldMode); + Assert.Equal(new ObjectId("7909961ae96accd75b6813d32e0fc1d6d52ec941"), entryChanges.OldOid); + } + } + } + + } +} From 1ac88c8271787c2fae8f53aae8a3f6633cbc46f6 Mon Sep 17 00:00:00 2001 From: Orn Kristjansson Date: Wed, 23 Nov 2016 15:32:18 -0700 Subject: [PATCH 4/6] Beefed PatchEntryChanges coverage to 100% (reverted from commit 8c9791b6a0df6224af4d8473b7903dd74466882a) --- LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj | 1 - .../PatchEntryChangesFixture.cs | 47 ------------------- 2 files changed, 48 deletions(-) delete mode 100644 LibGit2Sharp.Tests/PatchEntryChangesFixture.cs diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj index 24abbb804..0be3440c6 100644 --- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj +++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj @@ -65,7 +65,6 @@ - diff --git a/LibGit2Sharp.Tests/PatchEntryChangesFixture.cs b/LibGit2Sharp.Tests/PatchEntryChangesFixture.cs deleted file mode 100644 index 2d5c1030a..000000000 --- a/LibGit2Sharp.Tests/PatchEntryChangesFixture.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; -using LibGit2Sharp.Tests.TestHelpers; -using Xunit; -using Xunit.Extensions; - - -namespace LibGit2Sharp.Tests -{ - public class PatchEntryChangesFixture : BaseFixture - { - - [Fact] - public void PatchEntryBasics() - { - // Init test repo - var path = SandboxStandardTestRepoGitDir(); - string file = "numbers.txt"; - - // The repo - using (var repo = new Repository(path)) - { - Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; - Tree commitTreeWithUpdatedFile = repo.Lookup("ec9e401").Tree; - - // Create path by diffing - using (var patch = repo.Diff.Compare(rootCommitTree, commitTreeWithUpdatedFile)) - { - PatchEntryChanges entryChanges = patch[file]; - Assert.Equal(2, entryChanges.LinesAdded); - Assert.Equal(1, entryChanges.LinesDeleted); - Assert.Equal(187, entryChanges.Patch.Length); - // Smoke test - Assert.Equal(Mode.NonExecutableFile, entryChanges.Mode); - Assert.Equal(new ObjectId("4625a3628cb78970c57e23a2fe2574514ba403c7"), entryChanges.Oid); - Assert.Equal(ChangeKind.Modified, entryChanges.Status); - Assert.Equal(file, entryChanges.OldPath); - Assert.Equal(Mode.NonExecutableFile, entryChanges.OldMode); - Assert.Equal(new ObjectId("7909961ae96accd75b6813d32e0fc1d6d52ec941"), entryChanges.OldOid); - } - } - } - - } -} From 731bbffb1330f6abc317dfa6a98d3b75337276e3 Mon Sep 17 00:00:00 2001 From: Orn Kristjansson Date: Wed, 23 Nov 2016 15:32:52 -0700 Subject: [PATCH 5/6] Removed HandlesSubDirectorySeperators test (reverted from commit f106092db40448a4488cec4afaf53813904d62f2) --- LibGit2Sharp.Tests/FileHistoryFixture.cs | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/LibGit2Sharp.Tests/FileHistoryFixture.cs b/LibGit2Sharp.Tests/FileHistoryFixture.cs index d031f810b..4a4148738 100644 --- a/LibGit2Sharp.Tests/FileHistoryFixture.cs +++ b/LibGit2Sharp.Tests/FileHistoryFixture.cs @@ -290,6 +290,35 @@ public void UnsupportedSortStrategyThrows() } } + [Theory] + [InlineData("https://github.com/ornatwork/nugetpackages")] + public void HandlesSubDirectorySeperators(string url) + { + var scd = BuildSelfCleaningDirectory(); + var clonedRepoPath = Repository.Clone(url, scd.DirectoryPath); + string subdir1 = "devbox"; + string subdir2_double_backslash = subdir1 + Path.DirectorySeparatorChar + "content"; + string subdir2_forwardslash = subdir1 + Path.AltDirectorySeparatorChar + "content"; + + // Check + using (var repo = new Repository(clonedRepoPath)) + { + // Total commits for repo + Assert.True( repo.Commits.Count() > 7 ); + // Subdir1 + IEnumerable history1 = repo.Commits.QueryBy(subdir1); + Assert.True(history1.Count() > 1); + + // subdir2 using double backslash + IEnumerable history1_1 = repo.Commits.QueryBy(subdir2_double_backslash); + Assert.True(history1_1.Count() > 0); + + // subdir2 using forward slash + IEnumerable history2_1 = repo.Commits.QueryBy(subdir2_forwardslash); + Assert.True(history2_1.Count() > 0); + } + } + #region Helpers private Signature _signature = Constants.Signature; From c817e8747e41439fd7c01788b3810b016e47e118 Mon Sep 17 00:00:00 2001 From: Orn Kristjansson Date: Wed, 23 Nov 2016 15:33:24 -0700 Subject: [PATCH 6/6] Test to show forward and backslashes in sub directories are handled correctly. Ref https://github.com/libgit2/libgit2sharp/issues/1075 (reverted from commit de4d5e5e4c551338e237d4587008abf3650903ae) --- LibGit2Sharp.Tests/FileHistoryFixture.cs | 33 ++---------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/LibGit2Sharp.Tests/FileHistoryFixture.cs b/LibGit2Sharp.Tests/FileHistoryFixture.cs index 4a4148738..c74165fcf 100644 --- a/LibGit2Sharp.Tests/FileHistoryFixture.cs +++ b/LibGit2Sharp.Tests/FileHistoryFixture.cs @@ -290,38 +290,9 @@ public void UnsupportedSortStrategyThrows() } } - [Theory] - [InlineData("https://github.com/ornatwork/nugetpackages")] - public void HandlesSubDirectorySeperators(string url) - { - var scd = BuildSelfCleaningDirectory(); - var clonedRepoPath = Repository.Clone(url, scd.DirectoryPath); - string subdir1 = "devbox"; - string subdir2_double_backslash = subdir1 + Path.DirectorySeparatorChar + "content"; - string subdir2_forwardslash = subdir1 + Path.AltDirectorySeparatorChar + "content"; - - // Check - using (var repo = new Repository(clonedRepoPath)) - { - // Total commits for repo - Assert.True( repo.Commits.Count() > 7 ); - // Subdir1 - IEnumerable history1 = repo.Commits.QueryBy(subdir1); - Assert.True(history1.Count() > 1); - - // subdir2 using double backslash - IEnumerable history1_1 = repo.Commits.QueryBy(subdir2_double_backslash); - Assert.True(history1_1.Count() > 0); - - // subdir2 using forward slash - IEnumerable history2_1 = repo.Commits.QueryBy(subdir2_forwardslash); - Assert.True(history2_1.Count() > 0); - } - } - - #region Helpers + #region Helpers - private Signature _signature = Constants.Signature; + private Signature _signature = Constants.Signature; private const string SubFolderPath1 = "SubFolder1"; private Signature GetNextSignature()