Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0b1c2cc
(build deps): Bump actions/stale from 7 to 8
dependabot[bot] Mar 23, 2023
ad77771
Merge pull request #3448 from GitTools/dependabot/github_actions/acti…
arturcic Mar 24, 2023
20d3752
(deps): Bump JsonSchema.Net.Generation from 3.0.3 to 3.1.0
dependabot[bot] Mar 24, 2023
598b370
Merge pull request #3449 from GitTools/dependabot/nuget/JsonSchema.Ne…
arturcic Mar 25, 2023
27d4d0c
Made GitVersionVariables more like DTO
arturcic Mar 26, 2023
ba059b2
Renamed VersionVariables -> GitVersionVariables
arturcic Mar 26, 2023
23e2390
fixed approved files
arturcic Mar 26, 2023
065a34f
convert GitVersionVariables to record
arturcic Mar 26, 2023
516f2e7
removed ReflectionIgnore attribute from GitVersionVariable
arturcic Mar 26, 2023
83dbf0e
order properties
arturcic Mar 26, 2023
5edab63
added GitVersion.Abstractions
arturcic Mar 19, 2023
2adb521
moved Agents ang Git interfaces
arturcic Mar 26, 2023
8d8496c
moved some Configuration interfaces
arturcic Mar 26, 2023
a2299d0
use configuration builder in init module
arturcic Mar 27, 2023
6401cd4
use BranchConfigurationBuilder
arturcic Mar 28, 2023
683ca38
move more interfaces to Abstractions
arturcic Mar 28, 2023
06d76e5
decoupled modules from core and use abstractions instead
arturcic Mar 28, 2023
ea49bfa
fix api analyzer errors
arturcic Mar 28, 2023
7feae1d
Merge pull request #3451 from arturcic/feature/abstractions
arturcic Mar 28, 2023
488a150
Revert "Added GitVersion.Abstractions module"
arturcic Mar 28, 2023
d187a01
Merge pull request #3452 from GitTools/revert-3451-feature/abstractions
arturcic Mar 29, 2023
059ee5f
made classes that should not be exposed, internal (App, MsBuild and O…
arturcic Mar 29, 2023
8b6f878
use IGitVersionConfiguration instead of GitVersionConfiguration
arturcic Mar 29, 2023
458090a
use IBranchConfiguration instead of BranchConfiguration
arturcic Mar 29, 2023
71e0e98
Merge pull request #3454 from arturcic/feature/configuration
arturcic Mar 29, 2023
1cb9bb8
made classes that should not be exposed, internal (Core)
arturcic Mar 30, 2023
dfa86cb
#2665 - fix issues templates
arturcic Apr 4, 2023
f1ced75
Merge pull request #3457 from arturcic/bug/2665
arturcic Apr 4, 2023
d92fdc9
(ci deps): Bump Cake.Http from 2.0.0 to 3.0.2 in /build
dependabot[bot] Apr 4, 2023
0acceaf
Fix Bug: Branch names cannot contain the word 'refs' #3103
HHobeck Apr 4, 2023
1ef74f4
Merge pull request #3459 from HHobeck/feature/3103_branch-name-cannot…
arturcic Apr 4, 2023
4e6051a
Merge pull request #3458 from GitTools/dependabot/nuget/build/Cake.Ht…
arturcic Apr 4, 2023
eb35aff
Added failing tests for #1255, #1844, #2034, #2454, #2693, #2821, #2786
arturcic Mar 19, 2023
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
Prev Previous commit
Next Next commit
removed ReflectionIgnore attribute from GitVersionVariable
  • Loading branch information
arturcic committed Mar 26, 2023
commit 516f2e7b64d634254f8dc400a41ba29e4a3f70ad
72 changes: 27 additions & 45 deletions src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ public void CacheKeySameAfterReNormalizing()
const string targetUrl = "https://github.com/GitTools/GitVersion.git";
const string targetBranch = $"refs/head/{MainBranch}";

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 All @@ -55,11 +50,7 @@ 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 @@ -82,11 +73,7 @@ public void CacheKeyForWorktree()

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 = MainBranch }, WorkingDirectory = worktreePath };

this.sp = GetServiceProvider(gitVersionOptions);

Expand Down Expand Up @@ -148,7 +135,11 @@ public void CacheFileExistsOnDisk()
var versionVariables = gitVersionCalculator.CalculateVersionVariables();
versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");

this.fileSystem.WriteAllText(versionVariables.FileName, versionCacheFileContent);
var cacheKeyFactory = this.sp.GetRequiredService<IGitVersionCacheKeyFactory>();
var cacheKey = cacheKeyFactory.Create(null);
var cacheFileName = this.gitVersionCache.GetCacheFileName(cacheKey);

this.fileSystem.WriteAllText(cacheFileName, versionCacheFileContent);
versionVariables = gitVersionCalculator.CalculateVersionVariables();
versionVariables.AssemblySemVer.ShouldBe("4.10.3.0");

Expand Down Expand Up @@ -195,7 +186,10 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
var versionVariables = gitVersionCalculator.CalculateVersionVariables();
versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");

this.fileSystem.WriteAllText(versionVariables.FileName, versionCacheFileContent);
var cacheKeyFactory = this.sp.GetRequiredService<IGitVersionCacheKeyFactory>();
var cacheKey = cacheKeyFactory.Create(null);
var cacheFileName = this.gitVersionCache.GetCacheFileName(cacheKey);
this.fileSystem.WriteAllText(cacheFileName, versionCacheFileContent);

var cacheDirectory = this.gitVersionCache.GetCacheDirectory();

Expand All @@ -204,11 +198,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
var configuration = GitFlowConfigurationBuilder.New.WithLabelPrefix("prefix").Build();
var overrideConfiguration = new ConfigurationHelper(configuration).Dictionary;

gitVersionOptions = new GitVersionOptions
{
WorkingDirectory = fixture.RepositoryPath,
ConfigurationInfo = { OverrideConfiguration = overrideConfiguration }
};
gitVersionOptions = new GitVersionOptions { WorkingDirectory = fixture.RepositoryPath, ConfigurationInfo = { OverrideConfiguration = overrideConfiguration } };

gitVersionCalculator = GetGitVersionCalculator(gitVersionOptions);
versionVariables = gitVersionCalculator.CalculateVersionVariables();
Expand Down Expand Up @@ -283,9 +273,12 @@ public void ConfigChangeInvalidatesCache(string configFileName)
var versionVariables = gitVersionCalculator.CalculateVersionVariables();

versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");
versionVariables.FileName.ShouldNotBeNullOrEmpty();

this.fileSystem.WriteAllText(versionVariables.FileName, versionCacheFileContent);
var cacheKeyFactory = this.sp.GetRequiredService<IGitVersionCacheKeyFactory>();
var cacheKey = cacheKeyFactory.Create(null);
var cacheFileName = this.gitVersionCache.GetCacheFileName(cacheKey);

this.fileSystem.WriteAllText(cacheFileName, versionCacheFileContent);

versionVariables = gitVersionCalculator.CalculateVersionVariables();
versionVariables.AssemblySemVer.ShouldBe("4.10.3.0");
Expand Down Expand Up @@ -340,9 +333,12 @@ public void NoCacheBypassesCache()
var versionVariables = gitVersionCalculator.CalculateVersionVariables();

versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");
versionVariables.FileName.ShouldNotBeNullOrEmpty();

this.fileSystem.WriteAllText(versionVariables.FileName, versionCacheFileContent);
var cacheKeyFactory = this.sp.GetRequiredService<IGitVersionCacheKeyFactory>();
var cacheKey = cacheKeyFactory.Create(null);
var cacheFileName = this.gitVersionCache.GetCacheFileName(cacheKey);

this.fileSystem.WriteAllText(cacheFileName, versionCacheFileContent);
versionVariables = gitVersionCalculator.CalculateVersionVariables();
versionVariables.AssemblySemVer.ShouldBe("4.10.3.0");

Expand Down Expand Up @@ -394,11 +390,7 @@ public void GetProjectRootDirectoryWorkingDirectoryWithWorktree()

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 @@ -416,11 +408,7 @@ 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 All @@ -434,10 +422,7 @@ public void GetDotGitDirectoryNoWorktree()
{
using var fixture = new EmptyRepositoryFixture();

var gitVersionOptions = new GitVersionOptions
{
WorkingDirectory = fixture.RepositoryPath
};
var gitVersionOptions = new GitVersionOptions { WorkingDirectory = fixture.RepositoryPath };

this.sp = GetServiceProvider(gitVersionOptions);
var repositoryInfo = this.sp.GetRequiredService<IGitRepositoryInfo>();
Expand All @@ -459,10 +444,7 @@ public void GetDotGitDirectoryWorktree()
var repo = new Repository(fixture.RepositoryPath);
repo.Worktrees.Add("worktree", worktreePath, false);

var gitVersionOptions = new GitVersionOptions
{
WorkingDirectory = worktreePath
};
var gitVersionOptions = new GitVersionOptions { WorkingDirectory = worktreePath };

this.sp = GetServiceProvider(gitVersionOptions);
var repositoryInfo = this.sp.GetRequiredService<IGitRepositoryInfo>();
Expand Down
5 changes: 0 additions & 5 deletions src/GitVersion.Core/OutputVariables/GitVersionVariables.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using static GitVersion.Extensions.ObjectExtensions;

namespace GitVersion.OutputVariables;

public record GitVersionVariables(string Major,
Expand Down Expand Up @@ -86,9 +84,6 @@ public record GitVersionVariables(string Major,
{ nameof(UncommittedChanges), UncommittedChanges }
};

[ReflectionIgnore]
public string? FileName { get; set; }

public IEnumerator<KeyValuePair<string, string?>> GetEnumerator() => Instance.GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => Instance.GetEnumerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ private static GitVersionVariables FromFileInternal(string filePath, IFileSystem
using var reader = new StreamReader(stream);
var dictionary = new Deserializer().Deserialize<Dictionary<string, string>>(reader);
var versionVariables = FromDictionary(dictionary);
versionVariables.FileName = filePath;
return versionVariables;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ public GitVersionCache(IFileSystem fileSystem, ILog log, IGitRepositoryInfo repo

public void WriteVariablesToDiskCache(GitVersionCacheKey cacheKey, GitVersionVariables variablesFromCache)
{
var cacheDir = PrepareCacheDirectory();
var cacheFileName = GetCacheFileName(cacheKey, cacheDir);

variablesFromCache.FileName = cacheFileName;
var cacheFileName = GetCacheFileName(cacheKey);

Dictionary<string, string?> dictionary;
using (this.log.IndentLog("Creating dictionary"))
Expand All @@ -47,6 +44,13 @@ void WriteCacheOperation()
retryOperation.Execute(WriteCacheOperation);
}

public string GetCacheFileName(GitVersionCacheKey cacheKey)
{
var cacheDir = PrepareCacheDirectory();
var cacheFileName = GetCacheFileName(cacheKey, cacheDir);
return cacheFileName;
}

public string GetCacheDirectory()
{
var gitDir = this.repositoryInfo.DotGitDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public interface IGitVersionCache
void WriteVariablesToDiskCache(GitVersionCacheKey cacheKey, GitVersionVariables variablesFromCache);
string GetCacheDirectory();
GitVersionVariables? LoadVersionVariablesFromDiskCache(GitVersionCacheKey key);
string GetCacheFileName(GitVersionCacheKey cacheKey);
}