Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixes #602. Don't auto-curate packages with excluded dependencies. #604

Closed
wants to merge 1 commit into from

2 participants

@jeffhandley

No description provided.

@anurse
Collaborator

:shipit: - I wonder if there are cases where a curated feed will want to auto-curate dependencies of curated packages? Not something we need to care about now, just something to think about.

@jeffhandley

The dependency packages should be auto-curated if they meet the requirements for auto-curating. If they don't meet the requirements, then they would need explicit inclusion.

@jeffhandley

Wow, I had forgotten about this!

I will rebase the changes on Preview and get it pushed there.

@jeffhandley

This has been merged into Preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
36 Facts/PackageCurators/WebMatrixPackageCuratorFacts.cs
@@ -117,6 +117,42 @@ public void WillNotIncludeThePackageWhenNotTaggedAndThereIsT4Template()
}
[Fact]
+ public void WillNotIncludeThePackageWhenItDependsOnAPackageThatIsNotIncluded()
+ {
+ var curator = new TestableWebMatrixPackageCurator();
+ var stubGalleryPackage = CreateStubGalleryPackage();
+ stubGalleryPackage.Dependencies.Add(new PackageDependency { Id = "NotACuratedPackage" });
+
+ curator.Curate(stubGalleryPackage, CreateStubNuGetPackage().Object);
+
+ curator.StubCreatedCuratedPackageCmd.Verify(stub => stub.Execute(
+ It.IsAny<int>(),
+ It.IsAny<int>(),
+ It.IsAny<bool>(),
+ It.IsAny<bool>(),
+ It.IsAny<string>()), Times.Never());
+ }
+
+ [Fact]
+ public void WillNotIncludeThePackageWhenItDependsOnAPackageThatIsExcludedInTheFeed()
+ {
+ var curator = new TestableWebMatrixPackageCurator();
+ curator.StubCuratedFeed.Packages.Add(new CuratedPackage { AutomaticallyCurated = false, Included = false, PackageRegistration = new PackageRegistration { Id = "ManuallyExcludedPackage" } });
+
+ var stubGalleryPackage = CreateStubGalleryPackage();
+ stubGalleryPackage.Dependencies.Add(new PackageDependency { Id = "ManuallyExcludedPackage" });
+
+ curator.Curate(stubGalleryPackage, CreateStubNuGetPackage().Object);
+
+ curator.StubCreatedCuratedPackageCmd.Verify(stub => stub.Execute(
+ It.IsAny<int>(),
+ It.IsAny<int>(),
+ It.IsAny<bool>(),
+ It.IsAny<bool>(),
+ It.IsAny<string>()), Times.Never());
+ }
+
+ [Fact]
public void WillIncludeThePackageWhenThereIsNotPowerShellOrT4File()
{
var curator = new TestableWebMatrixPackageCurator();
View
40 Facts/PackageCurators/Windows8PackageCuratorFacts.cs
@@ -88,6 +88,46 @@ public void WillNotIncludeThePackageWhenTagsIsNull()
}
[Fact]
+ public void WillNotIncludeThePackageWhenItDependsOnAPackageThatIsNotIncluded()
+ {
+ var curator = new TestableWindows8PackageCurator();
+ var stubNuGetPackage = CreateStubNuGetPackage();
+
+ var stubGalleryPackage = CreateStubGalleryPackage();
+ stubGalleryPackage.Tags = "win8";
+ stubGalleryPackage.Dependencies.Add(new PackageDependency { Id = "NotACuratedPackage" });
+
+ curator.Curate(stubGalleryPackage, CreateStubNuGetPackage().Object);
+
+ curator.StubCreatedCuratedPackageCmd.Verify(stub => stub.Execute(
+ It.IsAny<int>(),
+ It.IsAny<int>(),
+ It.IsAny<bool>(),
+ It.IsAny<bool>(),
+ It.IsAny<string>()), Times.Never());
+ }
+
+ [Fact]
+ public void WillNotIncludeThePackageWhenItDependsOnAPackageThatIsExcludedInTheFeed()
+ {
+ var curator = new TestableWindows8PackageCurator();
+ curator.StubCuratedFeed.Packages.Add(new CuratedPackage { AutomaticallyCurated = false, Included = false, PackageRegistration = new PackageRegistration { Id = "ManuallyExcludedPackage" } });
+
+ var stubGalleryPackage = CreateStubGalleryPackage();
+ stubGalleryPackage.Tags = "win8";
+ stubGalleryPackage.Dependencies.Add(new PackageDependency { Id = "ManuallyExcludedPackage" });
+
+ curator.Curate(stubGalleryPackage, CreateStubNuGetPackage().Object);
+
+ curator.StubCreatedCuratedPackageCmd.Verify(stub => stub.Execute(
+ It.IsAny<int>(),
+ It.IsAny<int>(),
+ It.IsAny<bool>(),
+ It.IsAny<bool>(),
+ It.IsAny<string>()), Times.Never());
+ }
+
+ [Fact]
public void WillIncludeThePackageUsingTheCuratedFeedKey()
{
var curator = new TestableWindows8PackageCurator();
View
13 Website/PackageCurators/AutomaticPackageCurator.cs
@@ -1,4 +1,5 @@
-using System.Web.Mvc;
+using System.Linq;
+using System.Web.Mvc;
using NuGet;
namespace NuGetGallery
@@ -13,5 +14,15 @@ protected virtual T GetService<T>()
{
return DependencyResolver.Current.GetService<T>();
}
+
+ protected bool DependenciesAreCurated(Package galleryPackage, CuratedFeed curatedFeed)
+ {
+ if (galleryPackage != null && galleryPackage.Dependencies.AnySafe())
+ {
+ return galleryPackage.Dependencies.All(d => curatedFeed.Packages.Where(p => p.Included).Select(p => p.PackageRegistration.Id).Contains(d.Id));
+ }
+
+ return true;
+ }
}
}
View
11 Website/PackageCurators/TagBasedPackageCurator.cs
@@ -30,11 +30,14 @@ public override void Curate(Package galleryPackage, IPackage nugetPackage)
// Check if this package should be curated
if (tags.Any(tag => RequiredTags.Contains(tag, StringComparer.OrdinalIgnoreCase)))
{
- // It should! Add it to the curated feed
- GetService<ICreateCuratedPackageCommand>().Execute(
- feed.Key, galleryPackage.PackageRegistration.Key, automaticallyCurated: true);
+ // It should!
+ // But now we need to ensure that the package's dependencies are also curated
+ if (DependenciesAreCurated(galleryPackage, feed))
+ {
+ GetService<ICreateCuratedPackageCommand>().Execute(
+ feed.Key, galleryPackage.PackageRegistration.Key, automaticallyCurated: true);
+ }
}
-
}
}
}
View
7 Website/PackageCurators/WebMatrixPackageCurator.cs
@@ -1,4 +1,5 @@
using System.IO;
+using System.Linq;
using NuGet;
namespace NuGetGallery
@@ -6,7 +7,7 @@ namespace NuGetGallery
public class WebMatrixPackageCurator : AutomaticPackageCurator
{
public override void Curate(
- Package galleryPackage,
+ Package galleryPackage,
IPackage nugetPackage)
{
var curatedFeed = GetService<ICuratedFeedByNameQuery>().Execute("webmatrix");
@@ -32,11 +33,13 @@ public class WebMatrixPackageCurator : AutomaticPackageCurator
}
}
- if (shouldBeIncluded)
+ if (shouldBeIncluded && DependenciesAreCurated(galleryPackage, curatedFeed))
+ {
GetService<ICreateCuratedPackageCommand>().Execute(
curatedFeed.Key,
galleryPackage.PackageRegistration.Key,
automaticallyCurated: true);
+ }
}
}
}
Something went wrong with that request. Please try again.