namespace ClaudeDo.Releases;

public readonly record struct VersionCompareResult(bool IsNewer, bool Unparseable);

public static class VersionComparer
{
    public static VersionCompareResult Compare(string latest, string current)
    {
        var latestTrimmed = (latest ?? "").TrimStart('v', 'V');
        var currentTrimmed = (current ?? "").TrimStart('v', 'V');

        var unparseable = !Version.TryParse(latestTrimmed, out var lv)
                        | !Version.TryParse(currentTrimmed, out var cv);

        if (unparseable) return new VersionCompareResult(false, true);
        return new VersionCompareResult(lv > cv, false);
    }
}
