Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ public class GitVersionExecutorTests : TestBase
}
""";

private const string TargetUrl = "https://github.com/GitTools/FakeRepository.git";
private const string TargetBranch = "master";

[Test]
public void CacheKeySameAfterReNormalizing()
{
using var fixture = new EmptyRepositoryFixture();
const string targetUrl = "https://github.com/GitTools/GitVersion.git";
const string targetBranch = $"refs/head/{MainBranch}";
const string targetBranch = $"refs/head/{TargetBranch}";

var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl, TargetBranch = targetBranch }, WorkingDirectory = fixture.RepositoryPath, Settings = { NoNormalize = false } };
var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = TargetUrl, TargetBranch = targetBranch }, WorkingDirectory = fixture.RepositoryPath, Settings = { NoNormalize = false } };

var environment = new TestEnvironment();
environment.SetEnvironmentVariable(AzurePipelines.EnvironmentVariableName, "true");
Expand Down Expand Up @@ -94,9 +96,7 @@ public void CacheKeySameAfterReNormalizing()
[Test]
public void GitPreparerShouldNotFailWhenTargetPathNotInitialized()
{
const string targetUrl = "https://github.com/GitTools/GitVersion.git";

var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl }, WorkingDirectory = string.Empty };
var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = TargetUrl }, WorkingDirectory = string.Empty };
Should.NotThrow(() =>
{
this.sp = GetServiceProvider(gitVersionOptions);
Expand All @@ -119,9 +119,7 @@ public void CacheKeyForWorktree()
var repo = new Repository(fixture.RepositoryPath);
repo.Worktrees.Add("worktree", worktreePath, false);

const string targetUrl = "https://github.com/GitTools/GitVersion.git";

var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl, TargetBranch = MainBranch }, WorkingDirectory = worktreePath };
var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = TargetUrl, TargetBranch = TargetBranch }, WorkingDirectory = worktreePath };

this.sp = GetServiceProvider(gitVersionOptions);

Expand Down Expand Up @@ -339,9 +337,7 @@ public void GetProjectRootDirectoryWorkingDirectoryWithWorktree()
var repo = new Repository(fixture.RepositoryPath);
repo.Worktrees.Add("worktree", worktreePath, false);

const string targetUrl = "https://github.com/GitTools/GitVersion.git";

var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl }, WorkingDirectory = worktreePath };
var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = TargetUrl }, WorkingDirectory = worktreePath };

this.sp = GetServiceProvider(gitVersionOptions);
var repositoryInfo = this.sp.GetRequiredService<IGitRepositoryInfo>();
Expand All @@ -357,9 +353,8 @@ public void GetProjectRootDirectoryWorkingDirectoryWithWorktree()
public void GetProjectRootDirectoryNoWorktree()
{
using var fixture = new EmptyRepositoryFixture();
const string targetUrl = "https://github.com/GitTools/GitVersion.git";

var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = targetUrl }, WorkingDirectory = fixture.RepositoryPath };
var gitVersionOptions = new GitVersionOptions { RepositoryInfo = { TargetUrl = TargetUrl }, WorkingDirectory = fixture.RepositoryPath };

this.sp = GetServiceProvider(gitVersionOptions);
var repositoryInfo = this.sp.GetRequiredService<IGitRepositoryInfo>();
Expand Down
Loading