Skip to content

Commit 9957095

Browse files
authored
Merge pull request #6750 from NuGet/dev
[ReleasePrep][2018.12.10]RI of dev into master
2 parents 7bcc397 + f14275f commit 9957095

File tree

116 files changed

+2765
-1895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2765
-1895
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Data.SqlClient;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Microsoft.Extensions.CommandLineUtils;
9+
using NuGet.Services.Entities;
10+
using NuGetGallery;
11+
12+
namespace GalleryTools.Commands
13+
{
14+
public static class UpdateIsLatestCommand
15+
{
16+
public static void Configure(CommandLineApplication config)
17+
{
18+
config.Description = "Update IsLatest(Stable)(SemVer2) properties of all packages in the target NuGetGallery database. !!Please make sure you have created a back-up of your database first!!";
19+
config.HelpOption("-? | -h | --help");
20+
21+
var connectionstringOption = config.Option(
22+
"--connectionstring",
23+
"The SQL connectionstring of the target NuGetGallery database.",
24+
CommandOptionType.SingleValue);
25+
26+
config.OnExecute(async () => await ExecuteAsync(connectionstringOption));
27+
}
28+
29+
private static async Task<int> ExecuteAsync(
30+
CommandOption connectionStringOption)
31+
{
32+
if (!connectionStringOption.HasValue())
33+
{
34+
Console.Error.WriteLine($"The {connectionStringOption.Template} option is required.");
35+
return 1;
36+
}
37+
38+
Console.Write("Testing database connectivity...");
39+
40+
using (var sqlConnection = new SqlConnection(connectionStringOption.Value()))
41+
{
42+
try
43+
{
44+
await sqlConnection.OpenAsync();
45+
Console.WriteLine(" OK");
46+
}
47+
catch (Exception exception)
48+
{
49+
Console.WriteLine(" Failed");
50+
Console.Error.WriteLine(exception.Message);
51+
return -1;
52+
}
53+
54+
using (var entitiesContext = new EntitiesContext(sqlConnection, readOnly: false))
55+
{
56+
var packageRegistrationRepository = new EntityRepository<PackageRegistration>(entitiesContext);
57+
58+
var packageService = new CorePackageService(
59+
new EntityRepository<Package>(entitiesContext),
60+
packageRegistrationRepository,
61+
new EntityRepository<Certificate>(entitiesContext));
62+
63+
Console.WriteLine("Retrieving package registrations...");
64+
var packageRegistrations = packageRegistrationRepository.GetAll().ToList();
65+
Console.WriteLine($"Processing {packageRegistrations.Count} records...");
66+
67+
double counter = 0;
68+
foreach (var packageRegistration in packageRegistrations.OrderBy(pr => pr.Id))
69+
{
70+
var pct = 100 * counter++ / packageRegistrations.Count;
71+
72+
Console.Write($" [{pct.ToString("N2")} %] Updating {packageRegistration.Id} ...");
73+
await packageService.UpdateIsLatestAsync(packageRegistration, commitChanges: true);
74+
Console.WriteLine($" OK");
75+
}
76+
}
77+
}
78+
79+
Console.WriteLine("DONE");
80+
return 0;
81+
}
82+
}
83+
}

src/GalleryTools/Commands/VerifyApiKeyCommand.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
35
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
66
using Microsoft.Extensions.CommandLineUtils;
77
using NuGet.Services.Entities;
8-
using NuGetGallery;
98
using NuGetGallery.Infrastructure.Authentication;
109

1110
namespace GalleryTools.Commands
@@ -93,4 +92,4 @@ private static int Execute(
9392
return 0;
9493
}
9594
}
96-
}
95+
}

src/GalleryTools/GalleryTools.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<Compile Include="Commands\BackfillRepositoryMetadataCommand.cs" />
4848
<Compile Include="Commands\HashCommand.cs" />
4949
<Compile Include="Commands\ReflowCommand.cs" />
50+
<Compile Include="Commands\UpdateIsLatestCommand.cs" />
5051
<Compile Include="Commands\VerifyApiKeyCommand.cs" />
5152
<Compile Include="Program.cs" />
5253
<Compile Include="Properties\AssemblyInfo.cs" />

src/GalleryTools/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static int Main(params string[] args)
1818
commandLineApplication.Command("reflow", ReflowCommand.Configure);
1919
commandLineApplication.Command("fillrepodata", BackfillRepositoryMetadataCommand.Configure);
2020
commandLineApplication.Command("verifyapikey", VerifyApiKeyCommand.Configure);
21+
commandLineApplication.Command("updateIsLatest", UpdateIsLatestCommand.Configure);
2122

2223
try
2324
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Threading.Tasks;
7+
8+
namespace NuGet.Services.Search.Client
9+
{
10+
/// <summary>
11+
/// This interface is used to discover the service client.
12+
/// </summary>
13+
public interface IServiceDiscoveryClient
14+
{
15+
/// <summary>
16+
/// The function is used to retrieve the endpoint for the resource type.
17+
/// </summary>
18+
/// <param name="resourceType"> The resource type needed for retrieval</param>
19+
Task<IEnumerable<Uri>> GetEndpointsForResourceType(string resourceType);
20+
}
21+
}

src/NuGet.Services.Search.Client/Client/SearchClient.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public async Task<ServiceResponse<SearchResults>> Search(
7474
string query,
7575
string projectTypeFilter = null,
7676
bool includePrerelease = false,
77-
string curatedFeed = null,
7877
SortOrder sortBy = SortOrder.Relevance,
7978
int skip = 0,
8079
int take = 10,
@@ -111,11 +110,6 @@ public async Task<ServiceResponse<SearchResults>> Search(
111110
nameValue.Add("prerelease", "true");
112111
}
113112

114-
if (!String.IsNullOrEmpty(curatedFeed))
115-
{
116-
nameValue.Add("feed", curatedFeed);
117-
}
118-
119113
if (!isLuceneQuery)
120114
{
121115
nameValue.Add("luceneQuery", "false");

src/NuGet.Services.Search.Client/Client/ServiceDiscoveryClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace NuGet.Services.Search.Client
1212
{
13-
public class ServiceDiscoveryClient
13+
public class ServiceDiscoveryClient : IServiceDiscoveryClient
1414
{
1515
private readonly HttpClient _httpClient;
1616
private readonly Uri _serviceDiscoveryEndpoint;

src/NuGet.Services.Search.Client/NuGet.Services.Search.Client.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<Compile Include="Client\BaseUrlHealthIndicatorStore.cs" />
4949
<Compile Include="Client\IEndpointHealthIndicatorStore.cs" />
5050
<Compile Include="Client\IHealthIndicatorLogger.cs" />
51+
<Compile Include="Client\IServiceDiscoveryClient.cs" />
5152
<Compile Include="Client\NullHealthIndicatorLogger.cs" />
5253
<Compile Include="Client\RetryingHttpClientWrapper.cs" />
5354
<Compile Include="Client\SearchClient.cs" />

src/NuGetGallery.Core/CoreConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static class Folders
4040
public const string StatusFolderName = "status";
4141
public const string SymbolPackagesFolderName = "symbol-packages";
4242
public const string SymbolPackageBackupsFolderName = "symbol-package-backups";
43+
public const string FlatContainerFolderName = "v3-flatcontainer";
4344
}
4445

4546
public const string NuGetSymbolPackageFileExtension = ".snupkg";

src/NuGetGallery.Core/Entities/EntitiesContext.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public EntitiesContext(DbConnection connection, bool readOnly)
4848
}
4949

5050
public bool ReadOnly { get; private set; }
51-
public IDbSet<CuratedFeed> CuratedFeeds { get; set; }
52-
public IDbSet<CuratedPackage> CuratedPackages { get; set; }
5351
public IDbSet<PackageRegistration> PackageRegistrations { get; set; }
5452
public IDbSet<Credential> Credentials { get; set; }
5553
public IDbSet<Scope> Scopes { get; set; }
@@ -300,27 +298,6 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
300298
modelBuilder.Entity<PackageFramework>()
301299
.HasKey(pf => pf.Key);
302300

303-
modelBuilder.Entity<CuratedFeed>()
304-
.HasKey(cf => cf.Key);
305-
306-
modelBuilder.Entity<CuratedFeed>()
307-
.HasMany<CuratedPackage>(cf => cf.Packages)
308-
.WithRequired(cp => cp.CuratedFeed)
309-
.HasForeignKey(cp => cp.CuratedFeedKey);
310-
311-
modelBuilder.Entity<CuratedFeed>()
312-
.HasMany<User>(cf => cf.Managers)
313-
.WithMany()
314-
.Map(c => c.ToTable("CuratedFeedManagers")
315-
.MapLeftKey("CuratedFeedKey")
316-
.MapRightKey("UserKey"));
317-
318-
modelBuilder.Entity<CuratedPackage>()
319-
.HasKey(cp => cp.Key);
320-
321-
modelBuilder.Entity<CuratedPackage>()
322-
.HasRequired(cp => cp.PackageRegistration);
323-
324301
modelBuilder.Entity<PackageDelete>()
325302
.HasKey(pd => pd.Key)
326303
.HasMany(pd => pd.Packages)

0 commit comments

Comments
 (0)