Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GitTools/GitVersion
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6.0.1
Choose a base ref
...
head repository: GitTools/GitVersion
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6.0.2
Choose a head ref
  • 8 commits
  • 15 files changed
  • 5 contributors

Commits on Aug 6, 2024

  1. move msbuild properties default evaluation to targets file

    This fix ensure that all properties used by these msbuild properties are
    set by the previouse evalitiuon before computing the default value.
    Louis Seubert committed Aug 6, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e0b8ac7 View commit details
  2. Merge pull request #4142 from Louis9902/bugfix/msbuild_execution_error

    move msbuild properties default evaluation to targets file
    arturcic authored Aug 6, 2024
    Copy the full SHA
    0a2797f View commit details
  3. #4120 - update Breaking Changes, adding info about the removed legacy…

    … output variables
    arturcic committed Aug 6, 2024
    Copy the full SHA
    7b741c5 View commit details
  4. Merge pull request #4145 from arturcic/main

    #4120 - update Breaking Changes
    arturcic authored Aug 6, 2024
    Copy the full SHA
    170d3d1 View commit details

Commits on Aug 7, 2024

  1. Remove dependency on "git" cmdline

    This will simplify the publishing to winget
    arturcic committed Aug 7, 2024
    Copy the full SHA
    73c2433 View commit details
  2. Merge pull request #4147 from arturcic/main

    Remove dependency on "git" cmdline
    arturcic authored Aug 7, 2024
    Copy the full SHA
    ad76a5f View commit details

Commits on Aug 9, 2024

  1. (deps): Bump NUnit.Analyzers

    Bumps the analyzers group with 1 update in the /src directory: [NUnit.Analyzers](https://github.com/nunit/nunit.analyzers).
    
    
    Updates `NUnit.Analyzers` from 4.2.0 to 4.3.0
    - [Release notes](https://github.com/nunit/nunit.analyzers/releases)
    - [Changelog](https://github.com/nunit/nunit.analyzers/blob/master/CHANGES.md)
    - [Commits](nunit/nunit.analyzers@4.2.0...4.3.0)
    
    ---
    updated-dependencies:
    - dependency-name: NUnit.Analyzers
      dependency-type: direct:production
      update-type: version-update:semver-minor
      dependency-group: analyzers
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and arturcic committed Aug 9, 2024
    Copy the full SHA
    70ee4e0 View commit details
  2. Merge pull request #4152 from GitTools/dependabot/nuget/src/analyzers…

    …-6e32ee7cee
    
    (deps): Bump NUnit.Analyzers from 4.2.0 to 4.3.0 in /src in the analyzers group across 1 directory
    mergify[bot] authored Aug 9, 2024
    Copy the full SHA
    3021131 View commit details
13 changes: 13 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -71,6 +71,19 @@
* When creating a branch with name `hotfix/next` (by using the `GitFlow` workflow) or `release/next` (by the `GitHubFlow` workflow) the resulting version will yield to a patched version per default.
* If you have a tag `1.0.0` on `main` and branch from `main` to `release/1.0.1` then the next version number will be `1.1.0` when using the `GitFlow` workflow. This behavior is expected (but different compared to the `GitHubFlow` workflow) because on the `GitFlow` workflow you have an addition branch configuration with name hotfix where `is-release-branch` is set to `true`. That means if you want `1.0.1` as a next version you need to branch to `hotfix/1.0.1` or `hotfix/next`. On the other hand if you use the `GitHubFlow` workflow the next version number will be `1.0.1` because the increment on the `release` branch is set to `Patch`.
### Legacy Output Variables
The following legacy output variables have been removed in this version:
* `BuildMetaDataPadded`
* `LegacySemVer`
* `LegacySemVerPadded`
* `NuGetVersionV2`
* `NuGetVersion`
* `NuGetPreReleaseTagV2`
* `NuGetPreReleaseTag`
* `CommitsSinceVersionSourcePadded`
## v5.0.0
* Version numbers in branches other than `release` branches are no longer
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
<PackageVersion Include="Microsoft.Win32.Registry" Version="6.0.0-preview.5.21301.5" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="NUnit" Version="4.1.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.2.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.3.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
10 changes: 3 additions & 7 deletions src/GitVersion.App/GitVersionExecutor.cs
Original file line number Diff line number Diff line change
@@ -82,16 +82,13 @@ private int RunGitVersionTool(GitVersionOptions gitVersionOptions)
var error = $"An unexpected error occurred:{PathHelper.NewLine}{exception}";
this.log.Error(error);

this.log.Info("Attempting to show the current git graph (please include in issue): ");
this.log.Info("Showing max of 100 commits");

try
{
GitExtensions.DumpGraph(gitVersionOptions.WorkingDirectory, mess => this.log.Info(mess), 100);
GitExtensions.DumpGraphLog(logMessage => this.log.Info(logMessage));
}
catch (Exception dumpGraphException)
{
this.log.Error("Couldn't dump the git graph due to the following error: " + dumpGraphException);
this.log.Error($"Couldn't dump the git graph due to the following error: {dumpGraphException}");
}
return 1;
}
@@ -131,8 +128,7 @@ private bool HandleNonMainCommand(GitVersionOptions gitVersionOptions, out int e
var workingDirectory = gitVersionOptions.WorkingDirectory;
if (gitVersionOptions.Diag)
{
this.log.Info("Dumping commit graph: ");
GitExtensions.DumpGraph(workingDirectory, mess => this.log.Info(mess), 100);
GitExtensions.DumpGraphLog(logMessage => this.log.Info(logMessage));
}

if (!Directory.Exists(workingDirectory))
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ public static ICommit CreateMockCommit()
commit.When.Returns(when.AddSeconds(1));
return commit;
}

public static IBranch CreateMockBranch(string name, params ICommit[] commits)
{
var branch = Substitute.For<IBranch>();
@@ -55,13 +56,13 @@ public static void DiscoverRepository(this IServiceProvider sp)

public static IBranch FindBranch(this IGitRepository repository, string branchName)
=> repository.Branches.FirstOrDefault(branch => branch.Name.WithoutOrigin == branchName)
?? throw new GitVersionException($"Branch {branchName} not found");
?? throw new GitVersionException($"Branch {branchName} not found");

public static void DumpGraph(this IGitRepository repository, Action<string>? writer = null, int? maxCommits = null)
=> GitExtensions.DumpGraph(repository.Path, writer, maxCommits);
=> DumpGraph(repository.Path, writer, maxCommits);

public static void DumpGraph(this IRepository repository, Action<string>? writer = null, int? maxCommits = null)
=> GitExtensions.DumpGraph(repository.ToGitRepository().Path, writer, maxCommits);
=> DumpGraph(repository.ToGitRepository().Path, writer, maxCommits);

public static GitVersionVariables GetVersion(this RepositoryFixtureBase fixture, IGitVersionConfiguration? configuration = null,
IRepository? repository = null, string? commitId = null, bool onlyTrackedBranches = true, string? targetBranch = null)
@@ -173,4 +174,7 @@ private static IServiceProvider ConfigureServices(Action<IServiceCollection>? se
servicesOverrides?.Invoke(services);
return services.BuildServiceProvider();
}

private static void DumpGraph(string workingDirectory, Action<string>? writer = null, int? maxCommits = null)
=> GitTestExtensions.ExecuteGitCmd(GitExtensions.CreateGitLogArgs(maxCommits), workingDirectory, writer);
}
3 changes: 2 additions & 1 deletion src/GitVersion.Core/Core/GitVersionContextFactory.cs
Original file line number Diff line number Diff line change
@@ -29,7 +29,8 @@ public GitVersionContext Create(GitVersionOptions gitVersionOptions)
currentBranch, gitVersionOptions.RepositoryInfo.CommitId, configuration.Ignore
);

if (currentCommit is null) throw new GitVersionException("No commits found on the current branch.");
if (currentCommit is null)
throw new GitVersionException("No commits found on the current branch.");

if (currentBranch.IsDetachedHead)
{
23 changes: 3 additions & 20 deletions src/GitVersion.Core/Extensions/GitExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
using GitVersion.Helpers;

namespace GitVersion.Extensions;

public static class GitExtensions
{
public static void DumpGraph(string workingDirectory, Action<string>? writer = null, int? maxCommits = null)
public static void DumpGraphLog(Action<string>? writer = null, int? maxCommits = null)
{
var output = new StringBuilder();
try
{
ProcessHelper.Run(
o => output.AppendLine(o),
e => output.AppendLineFormat("ERROR: {0}", e),
null,
"git",
CreateGitLogArgs(maxCommits),
workingDirectory);
}
catch (FileNotFoundException exception) when (exception.FileName == "git")
{
output.AppendLine("Could not execute 'git log' due to the following error:");
output.AppendLine(exception.ToString());
}

output.AppendLine($"Please run `git {CreateGitLogArgs(maxCommits)}` to see the git graph. This can help you troubleshoot any issues.");
if (writer != null)
{
writer(output.ToString());
@@ -36,6 +19,6 @@ public static void DumpGraph(string workingDirectory, Action<string>? writer = n
public static string CreateGitLogArgs(int? maxCommits)
{
var commits = maxCommits != null ? $" -n {maxCommits}" : null;
return $@"log --graph --format=""%h %cr %d"" --decorate --date=relative --all --remotes=*{commits}";
return $"""log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=*{commits}""";
}
}
2 changes: 1 addition & 1 deletion src/GitVersion.Core/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -753,7 +753,7 @@ static GitVersion.Extensions.EnumerableExtensions.AddRange<T>(this System.Collec
static GitVersion.Extensions.EnumerableExtensions.OnlyOrDefault<T>(this System.Collections.Generic.IEnumerable<T>! source) -> T?
static GitVersion.Extensions.EnumerableExtensions.SingleOfType<T>(this System.Collections.IEnumerable! source) -> T
static GitVersion.Extensions.GitExtensions.CreateGitLogArgs(int? maxCommits) -> string!
static GitVersion.Extensions.GitExtensions.DumpGraph(string! workingDirectory, System.Action<string!>? writer = null, int? maxCommits = null) -> void
static GitVersion.Extensions.GitExtensions.DumpGraphLog(System.Action<string!>? writer = null, int? maxCommits = null) -> void
static GitVersion.Extensions.IncrementStrategyExtensions.ToVersionField(this GitVersion.IncrementStrategy strategy) -> GitVersion.VersionField
static GitVersion.Extensions.ReadEmbeddedResourceExtensions.ReadAsStringFromEmbeddedResource(this string! resourceName, System.Reflection.Assembly! assembly) -> string!
static GitVersion.Extensions.ReadEmbeddedResourceExtensions.ReadAsStringFromEmbeddedResource<T>(this string! resourceName) -> string!
Original file line number Diff line number Diff line change
@@ -245,7 +245,7 @@ public void GenerateGitVersionInformationTaskShouldCreateFileWhenRunWithMsBuildA
result.Output.ShouldContain($"{outputProperty}: {generatedFilePath}");

var fileContent = File.ReadAllText(generatedFilePath);
TestContext.WriteLine(fileContent);
TestContext.Out.WriteLine(fileContent);
fileContent.ShouldMatch(string.Format(regexPattern, nameof(GitVersionVariables.Major), "1"));
fileContent.ShouldMatch(string.Format(regexPattern, nameof(GitVersionVariables.Minor), "2"));
fileContent.ShouldMatch(string.Format(regexPattern, nameof(GitVersionVariables.Patch), "4"));
5 changes: 0 additions & 5 deletions src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props
Original file line number Diff line number Diff line change
@@ -16,11 +16,6 @@
<GitVersion_ToolArgments Condition=" '$(GitVersion_NoFetchEnabled)' == 'true' ">$(GitVersion_ToolArgments) -nofetch</GitVersion_ToolArgments>
<GitVersion_ToolArgments Condition=" '$(GitVersion_NoNormalizeEnabled)' == 'true' ">$(GitVersion_ToolArgments) -nonormalize</GitVersion_ToolArgments>
<GitVersion_ToolArgments Condition=" '$(GitVersion_NoCacheEnabled)' == 'true' ">$(GitVersion_ToolArgments) -nocache</GitVersion_ToolArgments>

<GitVersionTargetFramework Condition="'$(GitVersionTargetFramework)' == ''">$(TargetFramework)</GitVersionTargetFramework>

<GitVersionFileExe Condition="'$(GitVersionFileExe)' == ''">dotnet --roll-forward Major &quot;$([MSBuild]::EnsureTrailingSlash($(MSBuildThisFileDirectory)$(GitVersionTargetFramework)))gitversion.dll&quot;</GitVersionFileExe>
<GitVersionAssemblyFile Condition="'$(GitVersionAssemblyFile)' == ''">$([MSBuild]::EnsureTrailingSlash($(MSBuildThisFileDirectory)$(GitVersionTargetFramework)))GitVersion.MsBuild.dll</GitVersionAssemblyFile>
</PropertyGroup>

<PropertyGroup>
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@

<UpdateAssemblyInfo Condition=" '$(UpdateAssemblyInfo)' == 'true' And '$(GenerateGitVersionFiles)' == 'true' ">true</UpdateAssemblyInfo>
<GenerateGitVersionInformation Condition=" '$(GenerateGitVersionInformation)' == '' And '$(GenerateGitVersionFiles)' == 'true' ">true</GenerateGitVersionInformation>

<GitVersionTargetFramework Condition="'$(GitVersionTargetFramework)' == ''">$(TargetFramework)</GitVersionTargetFramework>
<GitVersionFileExe Condition="'$(GitVersionFileExe)' == ''">dotnet --roll-forward Major &quot;$([MSBuild]::EnsureTrailingSlash($(MSBuildThisFileDirectory)$(GitVersionTargetFramework)))gitversion.dll&quot;</GitVersionFileExe>
<GitVersionAssemblyFile Condition="'$(GitVersionAssemblyFile)' == ''">$([MSBuild]::EnsureTrailingSlash($(MSBuildThisFileDirectory)$(GitVersionTargetFramework)))GitVersion.MsBuild.dll</GitVersionAssemblyFile>
</PropertyGroup>

<UsingTask TaskName="GetVersion" AssemblyFile="$(GitVersionAssemblyFile)" />
6 changes: 3 additions & 3 deletions src/GitVersion.Testing/Fixtures/RepositoryFixtureBase.cs
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ public void Remove(string branch)
SequenceDiagram.Destroy(branch);
}

public static void Init(string path, string branchName = "main") => GitTestExtensions.ExecuteGitCmd($"init {path} -b {branchName}");
public static void Init(string path, string branchName = "main") => GitTestExtensions.ExecuteGitCmd($"init {path} -b {branchName}", ".");

public string MakeATaggedCommit(string tag)
{
@@ -165,8 +165,8 @@ protected static Repository CreateNewRepository(string path, string branchName,
/// </summary>
public void MakeShallow()
{
GitTestExtensions.ExecuteGitCmd($"-C {RepositoryPath} pull --depth 1");
GitTestExtensions.ExecuteGitCmd($"-C {RepositoryPath} gc --prune=all");
GitTestExtensions.ExecuteGitCmd($"-C {RepositoryPath} pull --depth 1", ".");
GitTestExtensions.ExecuteGitCmd($"-C {RepositoryPath} gc --prune=all", ".");
}

public void Fetch(string remote, FetchOptions? options = null)
4 changes: 2 additions & 2 deletions src/GitVersion.Testing/GitTestExtensions.cs
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ public static Commit CreatePullRequestRef(this IRepository repository, string fr
return commit;
}

public static void ExecuteGitCmd(string gitCmd, Action<string>? writer = null)
public static void ExecuteGitCmd(string gitCmd, string workingDirectory, Action<string>? writer = null)
{
var output = new StringBuilder();
try
@@ -80,7 +80,7 @@ public static void ExecuteGitCmd(string gitCmd, Action<string>? writer = null)
null,
"git",
gitCmd,
".");
workingDirectory);
}
catch (FileNotFoundException exception) when (exception.FileName == "git")
{
3 changes: 1 addition & 2 deletions src/GitVersion.Testing/GitVersion.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
@@ -7,6 +7,5 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\GitVersion.Core\Helpers\PathHelper.cs" Link="Helpers\PathHelper.cs" />
<Compile Include="..\GitVersion.Core\Helpers\ProcessHelper.cs" Link="Helpers\ProcessHelper.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace GitVersion.Helpers;
namespace GitVersion.Testing;

internal static class ProcessHelper
public static class ProcessHelper
{
private static readonly object LockObject = new();

2 changes: 2 additions & 0 deletions src/mark-shipped.ps1
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#! /usr/bin/env pwsh

[CmdletBinding(PositionalBinding = $false)]
param ()