Skip to content

Commit

Permalink
Merge pull request #326 from valadas/sort-versions
Browse files Browse the repository at this point in the history
Properly sorts versions instead of just alphabetically.
  • Loading branch information
david-poindexter authored Sep 4, 2021
2 parents da26e49 + 3f54279 commit f0203d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
18 changes: 3 additions & 15 deletions nvQuickSite/Controllers/PackageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private static IEnumerable<Package> GetGitHubPackages()

var ghPackage = new Package();

ghPackage.version = TrimTagName(release);
ghPackage.version = new System.Version(release.TagName.TrimStart('v').Split('-')[0]);

if (index == 0 &&
release.Name.IndexOf("rc", StringComparison.OrdinalIgnoreCase) >= 0 &&
Expand All @@ -200,8 +200,8 @@ private static IEnumerable<Package> GetGitHubPackages()
else if (!release.Name.ToUpperInvariant().Contains("RC") &&
installPackage != null)
{
ghPackage.did = "dnn-platform-" + ghPackage.version.Substring(0, 1);
ghPackage.name = "DNN Platform " + ghPackage.version.Substring(0, 1);
ghPackage.did = "dnn-platform-" + ghPackage.version.Major.ToString();
ghPackage.name = "DNN Platform " + ghPackage.version.Major.ToString();
ghPackage.url = installPackage.BrowserDownloadUrl;
ghPackage.upgradeurl = upgradePackage.BrowserDownloadUrl;
packages.Add(ghPackage);
Expand All @@ -221,17 +221,5 @@ private static IEnumerable<Package> GetGitHubPackages()
return packages;
}
}

private static string TrimTagName(Release release)
{
if (release.TagName != null && release.TagName[0] == 'v')
{
return release.TagName.Remove(0, 1);
}
else
{
return release.TagName;
}
}
}
}
6 changes: 5 additions & 1 deletion nvQuickSite/Models/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// You should have received a copy of the GNU General Public License
// along with nvQuickSite. If not, see <http://www.gnu.org/licenses/>.

using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace nvQuickSite.Models
{
/// <summary>
Expand All @@ -35,7 +38,8 @@ public class Package
/// <summary>
/// Gets or sets the package version.
/// </summary>
public string version { get; set; }
[JsonConverter(typeof(VersionConverter))]
public System.Version version { get; set; }

/// <summary>
/// Gets or sets the url to download the install package.
Expand Down
8 changes: 4 additions & 4 deletions nvQuickSite/Start.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void LoadPackageVersions(string packageId)
this.cboProductVersion.Items.Clear();
foreach (var package in this.Packages.Where(p => p.did == packageId).OrderByDescending(p => p.version))
{
this.cboProductVersion.Items.Add(new ComboItem(package.version, package.version));
this.cboProductVersion.Items.Add(new ComboItem(package.version.ToString(), package.version.ToString()));
}

if (this.cboProductVersion.Items.Count > 0)
Expand Down Expand Up @@ -208,7 +208,7 @@ private void DisplayPackagePath()
Package package;
var fileName = string.Empty;

package = this.Packages.FirstOrDefault(p => p.did == ((ComboItem)this.cboProductName.SelectedItem).Value && p.version == ((ComboItem)this.cboProductVersion.SelectedItem).Value);
package = this.Packages.FirstOrDefault(p => p.did == ((ComboItem)this.cboProductName.SelectedItem).Value && p.version == new System.Version(((ComboItem)this.cboProductVersion.SelectedItem).Value));
fileName = package.url.Split('/').Last();

var downloadDirectory = FileSystemController.GetDownloadDirectory();
Expand Down Expand Up @@ -237,7 +237,7 @@ private void GetOnlineVersion()
}

Package package;
package = this.Packages.FirstOrDefault(p => p.did == ((ComboItem)this.cboProductName.SelectedItem).Value && p.version == ((ComboItem)this.cboProductVersion.SelectedItem).Value);
package = this.Packages.FirstOrDefault(p => p.did == ((ComboItem)this.cboProductName.SelectedItem).Value && p.version == new System.Version(((ComboItem)this.cboProductVersion.SelectedItem).Value));
var url = package.url;
var fileName = package.url.Split('/').Last();

Expand Down Expand Up @@ -298,7 +298,7 @@ private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs
Package package;
var fileName = string.Empty;

package = this.Packages.FirstOrDefault(p => p.did == ((ComboItem)this.cboProductName.SelectedItem).Value && p.version == ((ComboItem)this.cboProductVersion.SelectedItem).Value);
package = this.Packages.FirstOrDefault(p => p.did == ((ComboItem)this.cboProductName.SelectedItem).Value && p.version == new System.Version(((ComboItem)this.cboProductVersion.SelectedItem).Value));
fileName = package.url.Split('/').Last();
this.downloadProgressLogTimer.Stop();
Log.Logger.Information("Completed download of {fileName}", fileName);
Expand Down

0 comments on commit f0203d2

Please sign in to comment.