devlooped / GitInfo

Git and SemVer Info from MSBuild, C# and VB
https://clarius.org/GitInfo
MIT License
549 stars 70 forks source link

New tag without version drop semver to zeros #319

Open kost-samsonov opened 11 months ago

kost-samsonov commented 11 months ago

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://raw.githubusercontent.com/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 commented 11 months ago

Please consider sponsoring to help prioritize issues 🙏.