Skip to content

Commit

Permalink
Add test for version height with path filters and merge conflict
Browse files Browse the repository at this point in the history
This demonstrates the repro for #658
  • Loading branch information
AArnott committed Sep 21, 2021
1 parent 0b29e5a commit 3866cd6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/NerdBank.GitVersioning.Tests/VersionOracleTests.cs
Expand Up @@ -751,6 +751,38 @@ public void GetVersion_PathFilterInTwoDeepSubDirAndVersionBump()
Assert.Equal(1, this.GetVersionHeight(relativeDirectory));
}

[Fact]
public void GetVersion_PathFilterPlusMerge()
{
this.InitializeSourceControl(withInitialCommit: false);
this.WriteVersionFile(new VersionOptions
{
Version = new SemanticVersion("1.0"),
PathFilters = new FilterPath[] { new FilterPath(".", string.Empty) },
});

string conflictedFilePath = Path.Combine(this.RepoPath, "foo.txt");

File.WriteAllText(conflictedFilePath, "foo");
Commands.Stage(this.LibGit2Repository, conflictedFilePath);
this.LibGit2Repository.Commit("Add foo.txt with foo content.", this.Signer, this.Signer);
Branch originalBranch = this.LibGit2Repository.Head;

Branch topicBranch = this.LibGit2Repository.Branches.Add("topic", "HEAD~1");
Commands.Checkout(this.LibGit2Repository, topicBranch);
File.WriteAllText(conflictedFilePath, "bar");
Commands.Stage(this.LibGit2Repository, conflictedFilePath);
this.LibGit2Repository.Commit("Add foo.txt with bar content.", this.Signer, this.Signer);

Commands.Checkout(this.LibGit2Repository, originalBranch);
MergeResult result = this.LibGit2Repository.Merge(topicBranch, this.Signer, new MergeOptions { FileConflictStrategy = CheckoutFileConflictStrategy.Ours });
Assert.Equal(MergeStatus.Conflicts, result.Status);
Commands.Stage(this.LibGit2Repository, conflictedFilePath);
this.LibGit2Repository.Commit("Merge two branches", this.Signer, this.Signer);

Assert.Equal(3, this.GetVersionHeight());
}

[Fact]
public void GetVersionHeight_ProjectDirectoryDifferentToVersionJsonDirectory()
{
Expand Down

0 comments on commit 3866cd6

Please sign in to comment.