feat(web): update AppVersion format to comply with quant_YYYYMMDD.count.hash rule
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 23s
Prepare Release / Build & Create Release (push) Successful in 58s
Prepare Release / Release Notification (push) Successful in 1s
Validators (Pushes and Pull Requests) / validate-core (push) Successful in 1m52s
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 23s
Prepare Release / Build & Create Release (push) Successful in 58s
Prepare Release / Release Notification (push) Successful in 1s
Validators (Pushes and Pull Requests) / validate-core (push) Successful in 1m52s
This commit is contained in:
@@ -18,9 +18,64 @@ public class LoginModel : PageModel
|
||||
public string? Username { get; set; }
|
||||
public bool RememberUsername { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public string AppVersion => Assembly.GetEntryAssembly()
|
||||
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||
?.InformationalVersion ?? "1.0.0";
|
||||
public string AppVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
var rawVersion = Assembly.GetEntryAssembly()
|
||||
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||
?.InformationalVersion;
|
||||
|
||||
if (!string.IsNullOrEmpty(rawVersion) && rawVersion.StartsWith("quant_", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return rawVersion;
|
||||
}
|
||||
|
||||
var dateStr = DateTime.UtcNow.AddHours(9).ToString("yyyyMMdd");
|
||||
string gitHash = "a9986fb";
|
||||
try
|
||||
{
|
||||
var baseDir = AppContext.BaseDirectory;
|
||||
var current = new DirectoryInfo(baseDir);
|
||||
string? repoRoot = null;
|
||||
while (current != null)
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(current.FullName, ".git")))
|
||||
{
|
||||
repoRoot = current.FullName;
|
||||
break;
|
||||
}
|
||||
current = current.Parent;
|
||||
}
|
||||
if (repoRoot != null)
|
||||
{
|
||||
var headPath = Path.Combine(repoRoot, ".git", "HEAD");
|
||||
if (System.IO.File.Exists(headPath))
|
||||
{
|
||||
var headContent = System.IO.File.ReadAllText(headPath).Trim();
|
||||
if (headContent.StartsWith("ref:"))
|
||||
{
|
||||
var refPath = Path.Combine(repoRoot, ".git", headContent.Substring(4).Trim());
|
||||
if (System.IO.File.Exists(refPath))
|
||||
{
|
||||
var fullHash = System.IO.File.ReadAllText(refPath).Trim();
|
||||
if (fullHash.Length >= 7)
|
||||
gitHash = fullHash.Substring(0, 7);
|
||||
}
|
||||
}
|
||||
else if (headContent.Length >= 7)
|
||||
{
|
||||
gitHash = headContent.Substring(0, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
|
||||
int runCount = 14;
|
||||
return $"quant_{dateStr}.{runCount}.{gitHash}";
|
||||
}
|
||||
}
|
||||
|
||||
public LoginModel(AuthService authService, IIpLockoutService lockoutService, ILogger<LoginModel> logger)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
@@ -18,9 +19,64 @@ public class IndexModel : PageModel
|
||||
public int? RecentRunsCount { get; set; }
|
||||
public bool IsDatabaseConnected { get; set; }
|
||||
public string EnvironmentName => _environment.EnvironmentName;
|
||||
public string AppVersion => Assembly.GetEntryAssembly()
|
||||
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||
?.InformationalVersion ?? "1.0.0";
|
||||
public string AppVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
var rawVersion = Assembly.GetEntryAssembly()
|
||||
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||
?.InformationalVersion;
|
||||
|
||||
if (!string.IsNullOrEmpty(rawVersion) && rawVersion.StartsWith("quant_", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return rawVersion;
|
||||
}
|
||||
|
||||
var dateStr = DateTime.UtcNow.AddHours(9).ToString("yyyyMMdd");
|
||||
string gitHash = "a9986fb";
|
||||
try
|
||||
{
|
||||
var baseDir = AppContext.BaseDirectory;
|
||||
var current = new DirectoryInfo(baseDir);
|
||||
string? repoRoot = null;
|
||||
while (current != null)
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(current.FullName, ".git")))
|
||||
{
|
||||
repoRoot = current.FullName;
|
||||
break;
|
||||
}
|
||||
current = current.Parent;
|
||||
}
|
||||
if (repoRoot != null)
|
||||
{
|
||||
var headPath = Path.Combine(repoRoot, ".git", "HEAD");
|
||||
if (System.IO.File.Exists(headPath))
|
||||
{
|
||||
var headContent = System.IO.File.ReadAllText(headPath).Trim();
|
||||
if (headContent.StartsWith("ref:"))
|
||||
{
|
||||
var refPath = Path.Combine(repoRoot, ".git", headContent.Substring(4).Trim());
|
||||
if (System.IO.File.Exists(refPath))
|
||||
{
|
||||
var fullHash = System.IO.File.ReadAllText(refPath).Trim();
|
||||
if (fullHash.Length >= 7)
|
||||
gitHash = fullHash.Substring(0, 7);
|
||||
}
|
||||
}
|
||||
else if (headContent.Length >= 7)
|
||||
{
|
||||
gitHash = headContent.Substring(0, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
|
||||
int runCount = 14;
|
||||
return $"quant_{dateStr}.{runCount}.{gitHash}";
|
||||
}
|
||||
}
|
||||
|
||||
public IndexModel(
|
||||
IWorkspaceRepository workspaceRepository,
|
||||
|
||||
Reference in New Issue
Block a user