C#: Re-implement the git version logic using an attribute.

This commit is contained in:
Cornelius Riemenschneider
2024-05-21 17:28:31 +02:00
parent 731b9412df
commit 767d427c1b
4 changed files with 59 additions and 10 deletions

View File

@@ -107,17 +107,14 @@ namespace Semmle.Extraction
{
get
{
// the resources for git information are always attached to the entry` assembly by our build system
// the attribute for the git information are always attached to the entry assembly by our build system
var assembly = Assembly.GetEntryAssembly();
var describeAllStream = assembly.GetManifestResourceStream("git-ql-describe-all.log");
var headSHAStream = assembly.GetManifestResourceStream("git-ql-rev-parse.log");
if (describeAllStream == null || headSHAStream == null)
var versionString = assembly!.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
if (versionString == null)
{
return "unknown (not built from internal bazel workspace)";
}
var describeAll = new StreamReader(describeAllStream).ReadToEnd().Trim('\n');
var headSHA = new StreamReader(headSHAStream).ReadToEnd().Trim('\n');
return $"{describeAll} ({headSHA})";
return versionString.InformationalVersion;
}
}