Added git versioning to stamp assemblies with the commit and a command that might work to retrieve the commit hash

This commit is contained in:
barelyprofessional
2025-05-11 12:08:43 -05:00
parent 2a99eea470
commit 16961f12d6
2 changed files with 23 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using System.Reflection;
using System.Text.RegularExpressions;
using KfChatDotNetBot.Models.DbModels;
using KfChatDotNetWsClient.Models.Events;
@@ -50,4 +51,21 @@ public class EnableGambaMessages : ICommand
botInstance.BotServices.TemporarilySuppressGambaMessages = false;
await botInstance.SendChatMessageAsync("Gamba notifs back on the menu", true);
}
}
public class GetVersionCommand : ICommand
{
public List<Regex> Patterns => [
new Regex("^version$")
];
public string? HelpText => null;
public UserRight RequiredRight => UserRight.Loser;
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
{
var version = Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
await botInstance.SendChatMessageAsync($"Bot compiled against {version.Split('+')[1]}", true);
}
}

View File

@@ -17,6 +17,10 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.4" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.7.115">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NLog" Version="5.4.0" />
<PackageReference Include="Raffinert.FuzzySharp" Version="2.0.3" />
<PackageReference Include="System.Runtime.Caching" Version="9.0.4" />