Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix app cast gen not working w/multiple dashes #624

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading