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

[ReleasePrep][2021.04.26] RI of dev into main #8553

Merged
merged 11 commits into from
May 5, 2021
Merged
12 changes: 9 additions & 3 deletions src/GalleryTools/Commands/BackfillCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Xml;
using System.Xml.Linq;
using GalleryTools.Utils;
using Microsoft.IdentityModel.JsonWebTokens;
using NuGet.Services.Sql;

namespace GalleryTools.Commands
Expand Down Expand Up @@ -116,8 +117,7 @@ public async Task Collect(SqlConnection connection, Uri serviceDiscoveryUri, Dat

var repository = new EntityRepository<Package>(context);

var packages = repository.GetAll()
.Include(p => p.PackageRegistration);
var packages = repository.GetAll().Include(p => p.PackageRegistration);
if (QueryIncludes != null)
{
packages = packages.Include(QueryIncludes);
Expand Down Expand Up @@ -233,6 +233,10 @@ public async Task Update(SqlConnection connection, string fileName)
var repository = new EntityRepository<Package>(context);

var packages = repository.GetAll().Include(p => p.PackageRegistration);
if (QueryIncludes != null)
{
packages = packages.Include(QueryIncludes);
}

using (var csv = CreateCsvReader(fileName))
{
Expand Down Expand Up @@ -355,7 +359,9 @@ private CsvReader CreateCsvReader(string fileName)

var reader = new StreamReader(fileName);

return new CsvReader(reader, configuration);
var csvReader = new CsvReader(reader, configuration);
csvReader.Configuration.MissingFieldFound = null;
return csvReader;
}

private Configuration CreateCsvConfiguration()
Expand Down
56 changes: 28 additions & 28 deletions src/GalleryTools/Commands/BackfillTfmMetadataCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,31 @@ protected override List<string> ReadMetadata(IList<string> files, NuspecReader n
try
{
supportedFrameworks = _packageService.GetSupportedFrameworks(nuspecReader, files);
}
catch (ArgumentException)
{
// do nothing--this is a known scenario and we'll skip this package quietly, which will give us a more useful error log file
}

foreach (var tfm in supportedFrameworks)
{
// We wrap this in a try-catch because some poorly-crafted portable TFMs will make it through GetSupportedFrameworks and fail here, e.g. for a
// non-existent profile name like "Profile1", which will cause GetShortFolderName to throw. We want to fail silently for these as this is a known
// scenario (more useful error log) and not failing will allow us to still capture all of the valid TFMs.
// See https://github.com/NuGet/NuGet.Client/blob/ba008e14611f4fa518c2d02ed78dfe5969e4a003/src/NuGet.Core/NuGet.Frameworks/NuGetFramework.cs#L297
// See https://github.com/NuGet/NuGet.Client/blob/ba008e14611f4fa518c2d02ed78dfe5969e4a003/src/NuGet.Core/NuGet.Frameworks/FrameworkNameProvider.cs#L487 }
try
foreach (var tfm in supportedFrameworks)
{
var tfmToAdd = tfm.ToShortNameOrNull();
if (!string.IsNullOrEmpty(tfmToAdd))
// We wrap this in a try-catch because some poorly-crafted portable TFMs will make it through GetSupportedFrameworks and fail here, e.g. for a
// non-existent profile name like "Profile1", which will cause GetShortFolderName to throw. We want to fail silently for these as this is a known
// scenario (more useful error log) and not failing will allow us to still capture all of the valid TFMs.
// See https://github.com/NuGet/NuGet.Client/blob/ba008e14611f4fa518c2d02ed78dfe5969e4a003/src/NuGet.Core/NuGet.Frameworks/NuGetFramework.cs#L297
// See https://github.com/NuGet/NuGet.Client/blob/ba008e14611f4fa518c2d02ed78dfe5969e4a003/src/NuGet.Core/NuGet.Frameworks/FrameworkNameProvider.cs#L487 }
try
{
supportedTFMs.Add(tfmToAdd);
var tfmToAdd = tfm.ToShortNameOrNull();
if (!string.IsNullOrEmpty(tfmToAdd))
{
supportedTFMs.Add(tfmToAdd);
}
}
catch
{
// skip this TFM and only collect well-formatted ones
}
}
catch
{
// skip this TFM and only collect well-formatted ones
}
}
catch (ArgumentException)
{
// do nothing--this is a known scenario and we'll skip this package quietly, which will give us a more useful error log file
}

return supportedTFMs;
}
Expand All @@ -79,17 +78,18 @@ protected override void UpdatePackage(Package package, List<string> metadata, En
{
// Note that extracting old TFMs may throw for formatting reasons. In this case we'll force a full replacement by leaving the collection empty.
var existingTFMs = Enumerable.Empty<string>();
if (package.SupportedFrameworks != null)
try
{
try
{
existingTFMs = package.SupportedFrameworks.Select(f => f.FrameworkName.GetShortFolderName()).OrderBy(f => f);
}
catch
if (package.SupportedFrameworks != null)
{
// do nothing and replace in full
// We'll force this enumerable to a list to force all potential throws
existingTFMs = package.SupportedFrameworks.Select(f => f.FrameworkName.GetShortFolderName()).OrderBy(f => f).ToList();
}
}
catch
{
// do nothing and replace in full
}

var newTFMs = metadata == null || metadata.Count == 0
? Enumerable.Empty<string>()
Expand Down
4 changes: 4 additions & 0 deletions src/NuGetGallery/App_Start/AppActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ private static void BundlingPostStart()
.Include("~/Scripts/gallery/clamp.js");
BundleTable.Bundles.Add(displayPackageScriptBundle);

var listPackagesScriptBundle = new ScriptBundle("~/Scripts/gallery/page-list-packages.min.js")
.Include("~/Scripts/gallery/page-list-packages.js");
BundleTable.Bundles.Add(listPackagesScriptBundle);

var managePackagesScriptBundle = new ScriptBundle("~/Scripts/gallery/page-manage-packages.min.js")
.Include("~/Scripts/gallery/page-manage-packages.js");
BundleTable.Bundles.Add(managePackagesScriptBundle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
<div class="form-field">
<label for="editIssueComment">Add comment</label>
<textarea id="editIssueComment" name="editIssueComment" data-bind="value: editIssueComment" rows="10"
placeholder="Add a comment..." autocomplete="off" autofocus></textarea>
placeholder="Add a comment. If resolving a DMCA request add offender account names (in single quotes, comma-delimited), offending package id, and resolution (no action, withdrawn, upheld). Example: accounts:'foo1','foo2' id:BarPkg resolution: upheld"
autocomplete="off" autofocus></textarea>
</div>
</fieldset>
</form>
Expand Down
1 change: 1 addition & 0 deletions src/NuGetGallery/NuGetGallery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,7 @@
<Content Include="App_Data\Files\Content\Symbols-Configuration.json" />
<Content Include="Scripts\gallery\instrumentation.js" />
<Content Include="Scripts\gallery\knockout-3.5.1.js" />
<Content Include="Scripts\gallery\page-list-packages.js" />
<Content Include="Views\Shared\SiteMenu.cshtml">
<SubType>Code</SubType>
</Content>
Expand Down
17 changes: 17 additions & 0 deletions src/NuGetGallery/Scripts/gallery/page-list-packages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$(function() {
'use strict';

$(".reserved-indicator").each(
function() {
var checkmarkImage = $(this);
checkmarkImage.popover({ trigger: 'hover focus' });
checkmarkImage.click(function() {
checkmarkImage.popover('show');
setTimeout(function() {
checkmarkImage.popover('destroy');
},
1000);
});
}
);
});
32 changes: 16 additions & 16 deletions src/NuGetGallery/Views/Packages/DisplayPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -726,20 +726,20 @@
<table aria-label="Version History of @Model.Id" class="table borderless">
<thead>
<tr>
<th>Version</th>
<th>Downloads</th>
<th>Last updated</th>
<th scope="col">Version</th>
<th scope="col">Downloads</th>
<th scope="col">Last updated</th>
@if (Model.CanDisplayPrivateMetadata)
{
<th>Status</th>
<th scope="col">Status</th>
}
@if (Model.IsCertificatesUIEnabled)
{
<th aria-hidden="true" abbr="Signature Information"></th>
<th scope="col" aria-hidden="true" abbr="Signature Information"></th>
}
@if (Model.IsPackageDeprecationEnabled || Model.IsPackageVulnerabilitiesEnabled)
{
<th aria-hidden="true" abbr="Package Warnings"></th>
<th scope="col" aria-hidden="true" abbr="Package Warnings"></th>
}
</tr>
</thead>
Expand All @@ -759,15 +759,15 @@
rowCount++;
@VersionListDivider(rowCount, versionsExpanded)
<tr class="@(packageVersion.IsCurrent(Model) ? "bg-info" : null)">
<td>
<td tabindex="0">
<a href="@Url.Package(packageVersion)" title="@packageVersion.FullVersion">
@packageVersion.Version.Abbreviate(30)
</a>
</td>
<td>
<td tabindex="0">
@packageVersion.DownloadCount.ToNuGetNumberString()
</td>
<td>
<td tabindex="0">
<span data-datetime="@packageVersion.LastUpdated.ToString("O")">@packageVersion.LastUpdated.ToNuGetShortDateString()</span>
@if (packageVersion.PushedBy != null)
{
Expand All @@ -780,7 +780,7 @@
{
var packageStatusSummary = packageVersion.PackageStatusSummary;

<td>
<td tabindex="0">
@if (packageStatusSummary == PackageStatusSummary.Listed ||
packageStatusSummary == PackageStatusSummary.Unlisted)
{
Expand All @@ -801,7 +801,7 @@
}
else
{
<td class="package-icon-cell">
<td tabindex="0" class="package-icon-cell">
<i class="ms-Icon ms-Icon--Ribbon package-icon" title="@packageVersion.SignatureInformation"></i>
</td>
}
Expand All @@ -813,7 +813,7 @@
}
else
{
<td class="package-icon-cell">
<td tabindex="0" class="package-icon-cell">
<i class="ms-Icon ms-Icon--Warning package-icon" title="@packageVersion.PackageWarningIconTitle"></i>
</td>
}
Expand All @@ -824,16 +824,16 @@
rowCount++;
@VersionListDivider(rowCount, versionsExpanded)
<tr class="deleted">
<td class="version">
<td tabindex="0" class="version">
@packageVersion.Version
</td>
<td>
<td tabindex="0">
@packageVersion.DownloadCount
</td>
<td>
<td tabindex="0">
<span data-datetime="@packageVersion.LastUpdated.ToString("O")">@packageVersion.LastUpdated.ToNuGetShortDateString()</span>
</td>
<td>
<td tabindex="0">
Deleted
</td>
<td colspan="2"></td>
Expand Down
14 changes: 9 additions & 5 deletions src/NuGetGallery/Views/Packages/UploadPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
@ViewHelpers.AjaxAntiForgeryToken(Html)
@ViewHelpers.PackagesBreadcrumb(Url, CurrentUser, true, @<text>Upload</text>)
<div class="text-left">
<p class="message">Your package file will be uploaded and hosted on the @(Config.Current.Brand) server (@(Config.Current.SiteRoot)).</p>
<p class="message">Your package file will be uploaded and on the @(Config.Current.Brand) server (@(Config.Current.SiteRoot)).</p>
<p class="message">
To learn more about authoring great packages, view our
<a href="https://docs.microsoft.com/nuget/create-packages/package-authoring-best-practices" alt="Best Practices" aria-label="Read here about publishing packages">Best Practices</a> page.
</p>
</div>
<div id="upload-package-container">
<h2>
Expand Down Expand Up @@ -60,10 +64,10 @@
</div>
}

<div id="symbols-replace-warning-container" class="hidden">
@ViewHelpers.AlertWarning(@<text>There is an existing symbols package (.snupkg) for the below package ID and version.
Submitting this request will replace the previously uploaded symbols package as well as the corresponding symbol files from the symbol server.</text>)
</div>
<div id="symbols-replace-warning-container" class="hidden">
@ViewHelpers.AlertWarning(@<text>There is an existing symbols package (.snupkg) for the below package ID and version.
Submitting this request will replace the previously uploaded symbols package as well as the corresponding symbol files from the symbol server.</text>)
</div>

@Html.Partial("_VerifyForm")
</div>
Expand Down
36 changes: 18 additions & 18 deletions src/NuGetGallery/Views/Packages/_VerifyMetadata.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@
<div data-bind="if: $data">
<!-- ko if: $data.Warnings && $data.Warnings.length > 0 -->
@ViewHelpers.AlertWarning(
@<span>
We found the following issue(s):
<ul data-bind="foreach: $data.Warnings">
<!-- ko if: typeof($data) === "string" -->
<li><span data-bind="text: $data"></span></li>
<!-- /ko -->
<!-- ko if: typeof($data) === "object" -->
<!-- ko if: $data.PlainTextMessage -->
<li><span data-bind="text: $data.PlainTextMessage"></span></li>
<!-- /ko -->
<!-- ko ifnot: $data.PlainTextMessage -->
<li><span data-bind="html: $data.RawHtmlMessage"></span></li>
<!-- /ko -->
<!-- /ko -->
</ul>
We recommend that you fix these issues and upload a new package.
<a href="https://docs.microsoft.com/en-us/nuget/policies/nuget-faq#managing-packages-on-nugetorg" alt="Read more" aria-label="Read more about managing packages on nuget.org">Read more</a><br />
</span>)
@<span>
We found the following issue(s):
<ul data-bind="foreach: $data.Warnings">
<!-- ko if: typeof($data) === "string" -->
<li><span data-bind="text: $data"></span></li>
<!-- /ko -->
<!-- ko if: typeof($data) === "object" -->
<!-- ko if: $data.PlainTextMessage -->
<li><span data-bind="text: $data.PlainTextMessage"></span></li>
<!-- /ko -->
<!-- ko ifnot: $data.PlainTextMessage -->
<li><span data-bind="html: $data.RawHtmlMessage"></span></li>
<!-- /ko -->
<!-- /ko -->
</ul>
We recommend that you fix these issues and upload a new package. To learn more about authoring great packages, view our
<a href="https://docs.microsoft.com/nuget/create-packages/package-authoring-best-practices" alt="Best Practices" aria-label="Read here about managing packages on nuget.org">Best Practices</a> page.<br />
</span>)
<!-- /ko -->

<div class="verify-package-field">
Expand Down
2 changes: 2 additions & 0 deletions src/NuGetGallery/Views/Shared/ListPackages.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,6 @@
location.href = '?q=@Uri.EscapeDataString(Model.SearchTerm)';
});
</script>

@Scripts.Render("~/Scripts/gallery/page-list-packages.min.js")
}
2 changes: 1 addition & 1 deletion src/NuGetGallery/Views/Shared/_ListPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<img class="reserved-indicator"
src="~/Content/gallery/img/reserved-indicator.svg"
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/reserved-indicator-20x20.png"))
title="@Strings.ReservedNamespace_ReservedIndicatorTooltip" />
data-content="@Strings.ReservedNamespace_ReservedIndicatorTooltip" tabindex="0" />
}

@if (showEditButton && (Model.CanEdit || Model.CanManageOwners || Model.CanUnlistOrRelist))
Expand Down
Loading