Skip to content

Commit

Permalink
Merge #4266 Let dev builds use future spec versions
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Nov 26, 2024
2 parents 118fac3 + 4881021 commit fd1a50c
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ All notable changes to this project will be documented in this file.
- [Multiple] Sort dependencies first in modpacks (#4252 by: HebaruSan)
- [Multiple] Allow installs and removals to be cancelled (#4253 by: HebaruSan)
- [CLI] Include `supports` relationship in `ckan show` (#4262 by: HebaruSan)
- [Multiple] Pre-release handling (#4260 by: HebaruSan)
- [Multiple] Pre-release handling (#4260, #4266 by: HebaruSan)

### Bugfixes

Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/AuthTokenListScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public AuthTokenScreen(ConsoleTheme theme) : base(theme)
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader()
=> $"{Meta.GetProductName()} {Meta.GetVersion()}";
=> $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Put description in top center
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/DeleteDirectoriesScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ directories.Selection is null
/// <summary>
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader() => $"{Meta.GetProductName()} {Meta.GetVersion()}";
protected override string LeftHeader() => $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Show the Delete Directories header
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/DependencyScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public DependencyScreen(ConsoleTheme theme,
/// <summary>
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader() => $"{Meta.GetProductName()} {Meta.GetVersion()}";
protected override string LeftHeader() => $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Put description in top center
Expand Down
4 changes: 2 additions & 2 deletions ConsoleUI/ExitScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ private void Draw(ConsoleTheme theme)
Console.Clear();

// Specially formatted snippets
var ckanPiece = new FancyLinePiece(Meta.GetProductName(), theme.ExitInnerBg, theme.ExitHighlightFg);
var ckanVersionPiece = new FancyLinePiece($"{Meta.GetProductName()} {Meta.GetVersion()}", theme.ExitInnerBg, theme.ExitHighlightFg);
var ckanPiece = new FancyLinePiece(Meta.ProductName, theme.ExitInnerBg, theme.ExitHighlightFg);
var ckanVersionPiece = new FancyLinePiece($"{Meta.ProductName} {Meta.GetVersion()}", theme.ExitInnerBg, theme.ExitHighlightFg);
var releaseLinkPiece = new FancyLinePiece("https://github.com/KSP-CKAN/CKAN/releases/latest", theme.ExitInnerBg, theme.ExitLinkFg);
var issuesLinkPiece = new FancyLinePiece("https://github.com/KSP-CKAN/CKAN/issues", theme.ExitInnerBg, theme.ExitLinkFg);
var authorsLinkPiece = new FancyLinePiece("https://github.com/KSP-CKAN/CKAN/graphs/contributors", theme.ExitInnerBg, theme.ExitLinkFg);
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/GameInstanceListScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public GameInstanceListScreen(ConsoleTheme theme,
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader()
=> $"{Meta.GetProductName()} {Meta.GetVersion()}";
=> $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Put description in top center
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/GameInstanceScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected GameInstanceScreen(ConsoleTheme theme, GameInstanceManager mgr, string
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader()
=> $"{Meta.GetProductName()} {Meta.GetVersion()}";
=> $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Return whether the fields currently are valid.
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/InstallFiltersScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public InstallFiltersScreen(ConsoleTheme theme, IConfiguration globalConfig, Gam
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader()
=> $"{Meta.GetProductName()} {Meta.GetVersion()}";
=> $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Put description in top center
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/ModInfoScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public ModInfoScreen(ConsoleTheme theme,
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader()
=> $"{Meta.GetProductName()} {Meta.GetVersion()}";
=> $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Put description in top center
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/ModListScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ is int i and > 0
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader()
=> $"{Meta.GetProductName()} {Meta.GetVersion()}";
=> $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Put description in top center
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/ProgressScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ProgressScreen(ConsoleTheme theme, string descrip, string initMsg = "")
/// Put CKAN 1.25.5 in upper left corner
/// </summary>
protected override string LeftHeader()
=> $"{Meta.GetProductName()} {Meta.GetVersion()}";
=> $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Put description of what we're doing in top center
Expand Down
2 changes: 1 addition & 1 deletion ConsoleUI/RepoScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected RepoScreen(ConsoleTheme theme,
/// Put CKAN 1.25.5 in top left corner
/// </summary>
protected override string LeftHeader()
=> $"{Meta.GetProductName()} {Meta.GetVersion()}";
=> $"{Meta.ProductName} {Meta.GetVersion()}";

/// <summary>
/// Put description in top center
Expand Down
2 changes: 1 addition & 1 deletion Core/CKANPathUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class CKANPathUtils
/// </summary>
public static readonly string AppDataPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
Meta.GetProductName());
Meta.ProductName);

private static readonly ILog log = LogManager.GetLogger(typeof(CKANPathUtils));

Expand Down
56 changes: 30 additions & 26 deletions Core/Meta.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;

using CKAN.Extensions;
using CKAN.Versioning;

namespace CKAN
Expand All @@ -13,37 +14,40 @@ public static class Meta
/// so we don't have to embed that string in many places
/// </summary>
/// <returns>"CKAN"</returns>
public static string GetProductName()
=> Assembly.GetExecutingAssembly()
.GetAssemblyAttribute<AssemblyProductAttribute>()
.Product;
public static readonly string ProductName =
Assembly.GetExecutingAssembly()
.GetAssemblyAttribute<AssemblyProductAttribute>()
.Product;

public static readonly ModuleVersion ReleaseVersion = new ModuleVersion(GetVersion());

public static bool IsNetKAN
=> Assembly.GetExecutingAssembly()
.GetAssemblyAttribute<AssemblyTitleAttribute>()
.Title.Contains("NetKAN");
public static readonly ModuleVersion SpecVersion =
// A dev build always has an odd patch version, and
// an odd number always ends with an odd digit in base 10
new Regex(@"^(?<prefix>v\d+\.)(?<minor>\d+)\.\d*[13579]\.")
.TryMatch(ReleaseVersion.ToString(), out Match? m)
&& int.TryParse(m.Groups["minor"].Value, out int minor)
? new ModuleVersion($"{m.Groups["prefix"]}{minor + 1}.999")
: ReleaseVersion;

public static string GetVersion(VersionFormat format = VersionFormat.Normal)
{
var version = Assembly
.GetExecutingAssembly()
.GetAssemblyAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
public static readonly bool IsNetKAN =
Assembly.GetExecutingAssembly()
.GetAssemblyAttribute<AssemblyTitleAttribute>()
.Title.Contains("NetKAN");

switch (format)
public static string GetVersion(VersionFormat format = VersionFormat.Normal)
=> "v" + (format switch
{
case VersionFormat.Normal:
return "v" + Assembly.GetExecutingAssembly()
.GetAssemblyAttribute<AssemblyFileVersionAttribute>()
.Version;
case VersionFormat.Full:
return $"v{version}";
default:
throw new ArgumentOutOfRangeException(nameof(format), format, null);
}
}
VersionFormat.Full =>
Assembly.GetExecutingAssembly()
.GetAssemblyAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion,

VersionFormat.Normal or _ =>
Assembly.GetExecutingAssembly()
.GetAssemblyAttribute<AssemblyFileVersionAttribute>()
.Version,
});

private static T GetAssemblyAttribute<T>(this Assembly assembly)
=> (T)assembly.GetCustomAttributes(typeof(T), false)
Expand Down
2 changes: 1 addition & 1 deletion Core/Types/CkanModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ bool IEquatable<CkanModule>.Equals(CkanModule? other)
/// Returns true if we support at least spec_version of the CKAN spec.
/// </summary>
internal static bool IsSpecSupported(ModuleVersion spec_version)
=> Meta.IsNetKAN || Meta.ReleaseVersion.IsGreaterThan(spec_version);
=> Meta.IsNetKAN || Meta.SpecVersion.IsGreaterThan(spec_version);

/// <summary>
/// Returns true if we support the CKAN spec used by this module.
Expand Down
8 changes: 4 additions & 4 deletions GUI/Main/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public Main(string[] cmdlineArgs,
// Set the window name and class for X11
if (Platform.IsX11)
{
HandleCreated += (sender, e) => X11.SetWMClass(Meta.GetProductName(),
Meta.GetProductName(), Handle);
HandleCreated += (sender, e) => X11.SetWMClass(Meta.ProductName,
Meta.ProductName, Handle);
}

currentUser = new GUIUser(this, Wait, StatusLabel, StatusProgress);
Expand Down Expand Up @@ -427,8 +427,8 @@ private void CurrentInstanceUpdated()

Util.Invoke(this, () =>
{
Text = $"{Meta.GetProductName()} {Meta.GetVersion()} - {CurrentInstance.game.ShortName} {CurrentInstance.Version()} -- {Platform.FormatPath(CurrentInstance.GameDir())}";
minimizeNotifyIcon.Text = $"{Meta.GetProductName()} - {CurrentInstance.Name}";
Text = $"{Meta.ProductName} {Meta.GetVersion()} - {CurrentInstance.game.ShortName} {CurrentInstance.Version()} -- {Platform.FormatPath(CurrentInstance.GameDir())}";
minimizeNotifyIcon.Text = $"{Meta.ProductName} - {CurrentInstance.Name}";
UpdateStatusBar();
});

Expand Down

0 comments on commit fd1a50c

Please sign in to comment.