Merge pull request #2072 from VictoriousRaptor/PrintWindowsBuildNumber

Print windows build number in log
This commit is contained in:
VictoriousRaptor 2023-05-04 07:14:06 +08:00 committed by GitHub
commit 803633ff05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 14 deletions

View file

@ -19,7 +19,7 @@ namespace Flow.Launcher.Infrastructure
public static readonly string RootDirectory = Directory.GetParent(ApplicationDirectory).ToString();
public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins);
public const string Issue = "https://github.com/Flow-Launcher/Flow.Launcher/issues/new/choose";
public const string IssuesUrl = "https://github.com/Flow-Launcher/Flow.Launcher/issues";
public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location.NonNull()).ProductVersion;
public static readonly string Dev = "Dev";
public const string Documentation = "https://flowlauncher.com/docs/#/usage-tips";

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.Win32;
namespace Flow.Launcher.Infrastructure.Exception
@ -63,7 +62,7 @@ namespace Flow.Launcher.Infrastructure.Exception
sb.AppendLine($"* Command Line: {Environment.CommandLine}");
sb.AppendLine($"* Timestamp: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
sb.AppendLine($"* Flow Launcher version: {Constant.Version}");
sb.AppendLine($"* OS Version: {Environment.OSVersion.VersionString}");
sb.AppendLine($"* OS Version: {GetWindowsFullVersionFromRegistry()}");
sb.AppendLine($"* IntPtr Length: {IntPtr.Size}");
sb.AppendLine($"* x64: {Environment.Is64BitOperatingSystem}");
sb.AppendLine($"* Python Path: {Constant.PythonPath}");
@ -173,5 +172,35 @@ namespace Flow.Launcher.Infrastructure.Exception
}
}
public static string GetWindowsFullVersionFromRegistry()
{
try
{
var buildRevision = GetWindowsRevisionFromRegistry();
var currentBuild = Environment.OSVersion.Version.Build;
return currentBuild.ToString() + "." + buildRevision;
}
catch
{
return Environment.OSVersion.VersionString;
}
}
public static string GetWindowsRevisionFromRegistry()
{
try
{
using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\"))
{
var buildRevision = registryKey.GetValue("UBR").ToString();
return buildRevision;
}
}
catch
{
return "0";
}
}
}
}

View file

@ -3,8 +3,6 @@ using System.Windows.Threading;
using NLog;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Exception;
using NLog.Fluent;
using Log = Flow.Launcher.Infrastructure.Logger.Log;
namespace Flow.Launcher.Helper
{
@ -31,11 +29,11 @@ namespace Flow.Launcher.Helper
//prevent application exist, so the user can copy prompted error info
e.Handled = true;
}
public static string RuntimeInfo()
{
var info = $"\nFlow Launcher version: {Constant.Version}" +
$"\nOS Version: {Environment.OSVersion.VersionString}" +
$"\nOS Version: {ExceptionFormatter.GetWindowsFullVersionFromRegistry()}" +
$"\nIntPtr Length: {IntPtr.Size}" +
$"\nx64: {Environment.Is64BitOperatingSystem}";
return info;

View file

@ -23,7 +23,7 @@ namespace Flow.Launcher
SetException(exception);
}
private static string GetIssueUrl(string website)
private static string GetIssuesUrl(string website)
{
if (!website.StartsWith("https://github.com"))
{
@ -31,10 +31,10 @@ namespace Flow.Launcher
}
if(website.Contains("Flow-Launcher/Flow.Launcher"))
{
return Constant.Issue;
return Constant.IssuesUrl;
}
var treeIndex = website.IndexOf("tree", StringComparison.Ordinal);
return treeIndex == -1 ? $"{website}/issues/new" : $"{website[..treeIndex]}/issues/new";
return treeIndex == -1 ? $"{website}/issues" : $"{website[..treeIndex]}/issues";
}
private void SetException(Exception exception)
@ -45,8 +45,8 @@ namespace Flow.Launcher
var websiteUrl = exception switch
{
FlowPluginException pluginException =>GetIssueUrl(pluginException.Metadata.Website),
_ => Constant.Issue
FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website),
_ => Constant.IssuesUrl
};
@ -86,4 +86,4 @@ namespace Flow.Launcher
return paragraph;
}
}
}
}

View file

@ -53,7 +53,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
{
// standard UrlSourceCode format in PluginsManifest's plugins.json file: https://github.com/jjw24/Flow.Launcher.Plugin.Putty/tree/master
var link = pluginManifestInfo.UrlSourceCode.StartsWith("https://github.com")
? Regex.Replace(pluginManifestInfo.UrlSourceCode, @"\/tree\/\w+$", "") + "/issues/new/choose"
? Regex.Replace(pluginManifestInfo.UrlSourceCode, @"\/tree\/\w+$", "") + "/issues"
: pluginManifestInfo.UrlSourceCode;
Context.API.OpenUrl(link);