Skip to content

Commit 5724d0f

Browse files
committed
add current git commit to vary id to improve cache dodge on update
1 parent 9680c26 commit 5724d0f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Utils/Utilities.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public static class Utilities
2626
/// <summary>StableSwarmUI's current version.</summary>
2727
public static readonly string Version = Assembly.GetEntryAssembly()?.GetName().Version.ToString();
2828

29+
/// <summary>Current git commit (if known -- empty if unknown).</summary>
30+
public static string GitCommit = "";
31+
2932
/// <summary>Used by linked pages to prevent cache errors when data changes.</summary>
3033
public static string VaryID = Version;
3134

@@ -39,6 +42,11 @@ public static class Utilities
3942

4043
static Utilities()
4144
{
45+
if (File.Exists("./.git/refs/heads/master"))
46+
{
47+
GitCommit = File.ReadAllText("./.git/refs/heads/master").Trim()[0..8];
48+
VaryID += ".GIT-" + GitCommit;
49+
}
4250
for (int i = 0; i <= 9; i++)
4351
{
4452
ReservedFilenames.Add($"com{i}");

0 commit comments

Comments
 (0)