Skip to content

Commit

Permalink
More update version check fixes + optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparronator9999 committed Jan 24, 2025
1 parent b216841 commit 52adc15
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion YAMDCC.Common/YAMDCC.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC common code library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.1</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Config/YAMDCC.Config.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC config library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.1</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.ConfigEditor/YAMDCC.ConfigEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Title>YAMDCC configuration utility</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.1</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.ECAccess/YAMDCC.ECAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC EC access library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.1</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.ECInspector/YAMDCC.ECInspector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Title>YAMDCC EC inspector</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.1</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Logs/YAMDCC.Logs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC logging library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.1</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Service/YAMDCC.Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC helper service</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.1</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
31 changes: 16 additions & 15 deletions YAMDCC.Updater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,39 @@ public static bool IsDevVersion(Release release)
public static bool IsUpdateAvailable(Release release)
{
string tag = release.TagName.Remove(0, 1),
latestSuffix = Utils.GetCurrentVerSuffix(),
currentSuffix = Utils.GetVerSuffix(tag);
currentSuffix = Utils.GetCurrentVerSuffix(),
latestSuffix = Utils.GetVerSuffix(tag);

Version current = Utils.GetCurrentVersion(),
latest = Utils.GetVersion(tag);
Version currentVer = Utils.GetCurrentVersion(),
latestVer = Utils.GetVersion(tag);

// check if version suffixes are different
// check if version suffixes are different,
// if they are, we probably need to update
if (latestSuffix != currentSuffix)
if (latestSuffix != string.Empty && latestSuffix != currentSuffix ||
latestSuffix == string.Empty && currentSuffix != "release")
{
return true;
}

if (current == latest)
if (currentVer == latestVer)
{
// check if pre-release version is out of date
int latestSuffixVer = Utils.GetSuffixVer(tag),
currentSuffixVer = Utils.GetCurrentSuffixVer(),
i = 0;

while (currentSuffixVer != -1 || latestSuffixVer != -1)
int i = 0, currentSuffixVer, latestSuffixVer;
do
{
currentSuffixVer = Utils.GetCurrentSuffixVer(i);
latestSuffixVer = Utils.GetSuffixVer(tag, i);

// this works even if current version
// doesn't have extra suffixes :)
if (currentSuffixVer < latestSuffixVer)
{
return true;
}
i++;
latestSuffixVer = Utils.GetSuffixVer(tag, i);
currentSuffixVer = Utils.GetCurrentSuffixVer(i);
}
while (currentSuffixVer != -1 || latestSuffixVer != -1);

// YAMDCC is up to date if we pass all these checks
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Updater/YAMDCC.Updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Title>YAMDCC configuration utility</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.1</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down

0 comments on commit 52adc15

Please sign in to comment.