Skip to content

Commit

Permalink
Merge pull request #748 from dotnet/stabilizeTests
Browse files Browse the repository at this point in the history
Stabilize tests against different default branch names
  • Loading branch information
AArnott committed May 1, 2022
2 parents 4815235 + f90a2fe commit a438bab
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/NerdBank.GitVersioning.Tests/RepoTestBase.cs
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 a438bab

Please sign in to comment.