File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,16 +25,21 @@ public override void Initialize()
2525 AvaloniaXamlLoader . Load ( this ) ;
2626
2727 var version = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ;
28+ var versionString = version ? . ToString ( version . Revision > 0 ? 4 : 3 ) ;
2829
2930#pragma warning disable CS0162 // Unreachable code detected
30- if ( Z2Randomizer . GitInfo . Branch == "main" )
31+ if ( versionString == Z2Randomizer . GitInfo . Tag && ! Z2Randomizer . GitInfo . IsDirty )
3132 {
32- Version = $ "v{ version ? . ToString ( version . Revision > 0 ? 4 : 3 ) } ";
33+ Version = $ "v{ versionString } ";
3334 }
34- else
35+ else if ( ! Z2Randomizer . GitInfo . IsDirty )
3536 {
3637 Version = $ "[{ Z2Randomizer . GitInfo . Branch } :{ Z2Randomizer . GitInfo . Commit } ]";
3738 }
39+ else
40+ {
41+ Version = $ "[{ Z2Randomizer . GitInfo . Branch } ]";
42+ }
3843#pragma warning restore CS0162 // Unreachable code detected
3944#if DEBUG
4045 Version += " (Debug)" ;
Original file line number Diff line number Diff line change 4848 <MakeDir Directories =" $(IntermediateOutputPath)" />
4949 <Exec Command =" git rev-parse --short HEAD > $(IntermediateOutputPath)git-hash.txt" />
5050 <Exec Command =" git rev-parse --abbrev-ref HEAD > $(IntermediateOutputPath)git-branch.txt" />
51+ <Exec Command =" git tag --points-at HEAD > $(IntermediateOutputPath)git-tag.txt" />
5152 <Exec Command =" git diff --quiet || echo dirty > $(IntermediateOutputPath)git-dirty.txt" IgnoreExitCode =" true" />
5253
5354 <ReadLinesFromFile File =" $(IntermediateOutputPath)git-hash.txt" ><Output TaskParameter =" Lines" PropertyName =" GitHash" /></ReadLinesFromFile >
5455 <ReadLinesFromFile File =" $(IntermediateOutputPath)git-branch.txt" ><Output TaskParameter =" Lines" PropertyName =" GitBranch" /></ReadLinesFromFile >
55- <ReadLinesFromFile File =" $(IntermediateOutputPath)git-dirty.txt" Condition =" Exists('$(IntermediateOutputPath)gitdirty.txt')" ><Output TaskParameter =" Lines" PropertyName =" GitDirty" /></ReadLinesFromFile >
56+ <ReadLinesFromFile File =" $(IntermediateOutputPath)git-tag.txt" ><Output TaskParameter =" Lines" ItemName =" GitTag" /></ReadLinesFromFile >
57+ <ReadLinesFromFile File =" $(IntermediateOutputPath)git-dirty.txt" Condition =" Exists('$(IntermediateOutputPath)git-dirty.txt')" ><Output TaskParameter =" Lines" PropertyName =" GitDirty" /></ReadLinesFromFile >
5658 <PropertyGroup ><IsDirtyValue >false</IsDirtyValue ></PropertyGroup >
5759 <PropertyGroup Condition =" '$(GitDirty)' != ''" ><IsDirtyValue >true</IsDirtyValue ></PropertyGroup >
5860 </Target >
5961
6062 <Target Name =" WriteGitInfoFile" DependsOnTargets =" GenerateGitInfo" BeforeTargets =" BeforeBuild" >
6163 <PropertyGroup >
64+ <GitTagsJoined >@(GitTag->'%(Identity)', ',')</GitTagsJoined >
6265 <GitInfoText >
6366 // (auto-generated from .csproj)
6467 namespace Z2Randomizer;
6972 {
7073 Commit = "$(GitHash)";
7174 Branch = "$(GitBranch)";
75+ Tag = "$(GitTagsJoined)";
7276 IsDirty = $(IsDirtyValue);
7377 }
7478 }
Original file line number Diff line number Diff line change 33public static partial class GitInfo
44{
55 public static string Commit { get ; } = "n/a" ;
6- public static string Branch { get ; } = "n/a" ;
6+ public static string Branch { get ; } = "unknown" ;
7+ public static string Tag { get ; } = "" ;
78 public static bool IsDirty { get ; }
89}
You can’t perform that action at this time.
0 commit comments