Skip to content

Commit

Permalink
Merge pull request #624 from NetSparkleUpdater/fix/appcast-multiple-h…
Browse files Browse the repository at this point in the history
…yphens

Fix app cast gen not working w/multiple dashes
  • Loading branch information
Deadpikle authored Oct 5, 2024
2 parents 2b4faa5 + 16f0100 commit 51542ca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ public void CanGetVersionFromName()
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("appsetup_2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("appsetup 2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("appsetup2.10.1.exe"));

// #623
Assert.Equal("1.3.0", AppCastMaker.GetVersionFromName("setup-something-1.3.0.dmg"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("app-setup-2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("my-app-setup-2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("my-app-setup-2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("my-app-setup 2.10.1.exe"));
Assert.Equal("2.1", AppCastMaker.GetVersionFromName("my--app-setup-2.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("-my--app-setup-2.10.1.exe"));

// Invalid semantic versions tests
Assert.Null(AppCastMaker.GetVersionFromName("app 1.2.3-0123.txt"));
Expand Down
9 changes: 4 additions & 5 deletions src/NetSparkle.Tools.AppCastGenerator/AppCastMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,16 @@ private static string RemoveTextBlockFromRight(string input)
// if segment has text in it at the start and digits later, get rid of text and +/- symbol
if (Regex.IsMatch(segment, @"[a-zA-Z]") && Regex.IsMatch(segment, @"\d"))
{
var match = Regex.Match(segment, @"[^+-]*[a-zA-Z][+-]?");
if (match.Success)
var match = Regex.Matches(segment, @"[^+-]*[a-zA-Z][+-]?");
if (match.Count > 0)
{
segment = segment.Substring(match.Index + match.Length);
segment = segment.Substring(match.Last().Index + match.Last().Length);
lastVersionToCheck = true;
}
}

tempSegment = string.IsNullOrWhiteSpace(tempSegment) ? segment : segment + "." + tempSegment;
tempSegment = tempSegment.Trim('.');

if (ContainsValidVersionInfo(tempSegment))
{
lastValidVersionLeft = tempSegment;
Expand Down Expand Up @@ -207,7 +206,7 @@ private static string RemoveTextBlockFromRight(string input)

// Handle a sampling of complex extensions and remove them if they exist
List<string> extensionPatterns = [@"\.tar\.gz$", @"\.tar$", @"\.gz$", @"\.zip$", @"\.txt$",
@"\.exe$", @"\.bin$", @"\.msi$", @"\.excel", @"\.mcdx", @"\.pdf", @"\.dll", @"\.ted"];
@"\.exe$", @"\.bin$", @"\.msi$", @"\.excel", @"\.mcdx", @"\.pdf", @"\.dll", @"\.ted", @"\.dmg"];
// handle user-defined extensions
if (extensions != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent />
<AssemblyVersion>2.8.1.0</AssemblyVersion>
<FileVersion>2.8.1.0</FileVersion>
<AssemblyVersion>2.8.2.0</AssemblyVersion>
<FileVersion>2.8.2.0</FileVersion>
<PackageId>NetSparkleUpdater.Tools.AppCastGenerator</PackageId>
<Version>2.8.1</Version>
<Version>2.8.2</Version>
<Authors>Deadpikle</Authors>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down

0 comments on commit 51542ca

Please sign in to comment.