Skip to content

Commit

Permalink
Stabilize tests against different default branch names
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed May 1, 2022
1 parent 68ebcd6 commit f90a2fe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/NerdBank.GitVersioning.Tests/RepoTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ protected virtual GitContext InitializeSourceControl(string repoPath, bool withI
{
Repository.Init(repoPath);
var repo = new Repository(repoPath);

// Our tests assume the default branch is master, so retain that regardless of global git configuration on the the machine running the tests.
if (repo.Head.FriendlyName != "master")
{
File.WriteAllText(Path.Combine(repoPath, ".git", "HEAD"), "ref: refs/heads/master\n");
}

repo.Config.Set("user.name", this.Signer.Name, ConfigurationLevel.Local);
repo.Config.Set("user.email", this.Signer.Email, ConfigurationLevel.Local);
foreach (var file in repo.RetrieveStatus().Untracked)
Expand Down

0 comments on commit f90a2fe

Please sign in to comment.