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

Use package's NormalizedVersion to create support requests #9285

Merged
merged 1 commit into from
Oct 27, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/NuGetGallery.Core/NuGetVersionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Text.RegularExpressions;
using NuGet.Services.Entities;
using NuGet.Versioning;

namespace NuGetGallery
Expand Down Expand Up @@ -31,6 +32,16 @@ public static string ToFullString(string version)
return version;
}
}

public static string GetNormalizedPackageVersion(Package package)
{
if (package == null)
{
return string.Empty;
}

return string.IsNullOrEmpty(package.NormalizedVersion) ? Normalize(package.Version) : package.NormalizedVersion;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we query the DB and see if this case happens at all? Even when I first joined the team I remember seeing NormalizedVersion populated every time we need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have just queried. This case doesn't exist.

}
}

public static class NuGetVersionExtensions
Expand Down
5 changes: 2 additions & 3 deletions src/NuGetGallery.Core/Services/FIleNameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ public static string BuildFileName(Package package, string format, string exten

return BuildFileName(
package.PackageRegistration.Id,
string.IsNullOrEmpty(package.NormalizedVersion) ?
NuGetVersionFormatter.Normalize(package.Version) :
package.NormalizedVersion, format, extension);
NuGetVersionFormatter.GetNormalizedPackageVersion(package),
format, extension);
}

public static string BuildFileName(string id, string version, string pathTemplate, string extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public async Task UpdateIssueAsync(int issueId, int? assignedToId, int issueStat
newIssue.CreatedBy = loggedInUser;
newIssue.OwnerEmail = requestorEmailAddress;
newIssue.PackageId = package?.PackageRegistration.Id;
newIssue.PackageVersion = package?.Version;
newIssue.PackageVersion = NuGetVersionFormatter.GetNormalizedPackageVersion(package);
newIssue.Reason = reason;
newIssue.SiteRoot = _siteRoot;
newIssue.UserKey = user?.Key;
Expand Down