Remove GitInfo dependency.

GitInfo doesn't work with the bazel-based build.
Instead, we pull in the information from bazel,
which correctly works with the bazel cache.
This commit is contained in:
Cornelius Riemenschneider
2024-05-06 10:30:36 +02:00
parent 71372bc74c
commit 36922f2625
7 changed files with 30 additions and 23 deletions

View File

@@ -30,8 +30,6 @@ codeql_csharp_library(
visibility = ["//csharp:__subpackages__"],
deps = [
"//csharp/extractor/Semmle.Util",
# "@paket.main//gitinfo",
# "@paket.main//thisassembly.git",
"@paket.main//microsoft.build",
"@paket.main//microsoft.codeanalysis",
],

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Reflection;
using System.IO;
using Semmle.Util.Logging;
using CompilationInfo = (string key, string value);
namespace Semmle.Extraction
@@ -102,7 +103,23 @@ namespace Semmle.Extraction
public ILogger Logger { get; private set; }
public static string Version => $"";
public static string Version
{
get
{
// the resources for 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)
{
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})";
}
}
public PathTransformer PathTransformer { get; }
}

View File

@@ -1,3 +1,2 @@
Microsoft.Build
Microsoft.CodeAnalysis
GitInfo