dependabot-nuget 0.297.1 → 0.297.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be53ff734b786bb3984f1b6930aae597fd26aa6848fb9e74607abca2e85b7098
4
- data.tar.gz: 254538df9bcc56e99bd1f4d8e9fe839794b40591f83e881f04890034df8bbd9c
3
+ metadata.gz: 303dd4ae4de15c33ca64bc0a8957ee6a4fa27cac4ffd2fbb93047d518d6afdb6
4
+ data.tar.gz: b4075db4bac953819932132e23d6478b6bc3e06242032d79235d2025caa1ed6f
5
5
  SHA512:
6
- metadata.gz: 4ae5ecf781b1a73da4cb1dc8cfc1675b572cd5fa525b819423f768eddab7fb86689ac6cfe222bc0b2289c36299c03c5d91738b78d38dbee04f92cbb58cc7cdca
7
- data.tar.gz: ab4dc1332f9108c4932aeb2f2c9491c5c064bc5fc618232e5c3156a4a96c7713b870cee954a00281aefffa7b0891c84ceb1fdd015af3939509655b015bbd9679
6
+ metadata.gz: 700973559052453bdfe9d999df2c980d1a5d95ecf296393edb1d1e030c050fa24eafd344898ed3017e2b6a19f7f61cf1503388ec875ffa093fc05b26cbbfc3a5
7
+ data.tar.gz: 3c3464e7f039d06e3fc55b3406e966767b2ed2e33d31c604f8034c7bde706aea942bcd5499b415ed1d8fae1b19323f57439e82b749e08ba0591aa53cab80aecb
@@ -0,0 +1,11 @@
1
+ namespace NuGetUpdater.Core;
2
+
3
+ internal class DependencyNotFoundException : Exception
4
+ {
5
+ public string[] Dependencies { get; }
6
+
7
+ public DependencyNotFoundException(string[] dependencies)
8
+ {
9
+ Dependencies = dependencies;
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ namespace NuGetUpdater.Core.Run.ApiModel;
2
+
3
+ public record DependencyNotFound : JobErrorBase
4
+ {
5
+ public DependencyNotFound(string dependency)
6
+ : base("dependency_not_found")
7
+ {
8
+ // the corresponding error type in Ruby calls this `source` but it's treated like a dependency name
9
+ Details["source"] = dependency;
10
+ }
11
+ }
@@ -25,6 +25,7 @@ public abstract record JobErrorBase
25
25
  return ex switch
26
26
  {
27
27
  BadRequirementException badRequirement => new BadRequirement(badRequirement.Message),
28
+ DependencyNotFoundException dependencyNotFound => new DependencyNotFound(string.Join(", ", dependencyNotFound.Dependencies)),
28
29
  HttpRequestException httpRequest => httpRequest.StatusCode switch
29
30
  {
30
31
  HttpStatusCode.Unauthorized or
@@ -970,12 +970,17 @@ internal static partial class MSBuildHelper
970
970
 
971
971
  private static void ThrowOnMissingPackages(string output)
972
972
  {
973
- var missingPackagesPattern = new Regex(@"Package '(?<PackageName>[^']*)' is not found on source");
974
- var matchCollection = missingPackagesPattern.Matches(output);
975
- var missingPackages = matchCollection.Select(m => m.Groups["PackageName"].Value).Distinct().ToArray();
976
- if (missingPackages.Length > 0)
973
+ var patterns = new[]
974
+ {
975
+ new Regex(@"Package '(?<PackageName>[^']*)' is not found on source '(?<PackageSource>[^$\r\n]*)'\."),
976
+ new Regex(@"Unable to find package (?<PackageName>[^ ]+)\. No packages exist with this id in source\(s\): (?<PackageSource>.*)$", RegexOptions.Multiline),
977
+ new Regex(@"Unable to find package (?<PackageName>[^ ]+) with version \((?<PackageVersion>[^)]+)\)"),
978
+ };
979
+ var matches = patterns.Select(p => p.Match(output)).Where(m => m.Success);
980
+ if (matches.Any())
977
981
  {
978
- throw new UpdateNotPossibleException(missingPackages);
982
+ var packages = matches.Select(m => m.Groups["PackageName"].Value).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
983
+ throw new DependencyNotFoundException(packages);
979
984
  }
980
985
  }
981
986
 
@@ -1294,4 +1294,65 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
1294
1294
  }
1295
1295
  );
1296
1296
  }
1297
+
1298
+ [Fact]
1299
+ public async Task MissingPackageIsCorrectlyReported_PackageNotFound()
1300
+ {
1301
+ await TestDiscoveryAsync(
1302
+ packages: [
1303
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.2.3", "net8.0", [(null, [("Transitive.Dependency.Does.Not.Exist", "4.5.6")])]),
1304
+ ],
1305
+ experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true },
1306
+ workspacePath: "",
1307
+ files: [
1308
+ ("project.csproj", """
1309
+ <Project Sdk="Microsoft.NET.Sdk">
1310
+ <PropertyGroup>
1311
+ <TargetFramework>net8.0</TargetFramework>
1312
+ </PropertyGroup>
1313
+ <ItemGroup>
1314
+ <PackageReference Include="Some.Package" Version="1.2.3" />
1315
+ </ItemGroup>
1316
+ </Project>
1317
+ """)
1318
+ ],
1319
+ expectedResult: new()
1320
+ {
1321
+ Path = "",
1322
+ Projects = [],
1323
+ Error = new DependencyNotFound("Transitive.Dependency.Does.Not.Exist"),
1324
+ }
1325
+ );
1326
+ }
1327
+
1328
+ [Fact]
1329
+ public async Task MissingPackageIsCorrectlyReported_VersionNotFound()
1330
+ {
1331
+ await TestDiscoveryAsync(
1332
+ packages: [
1333
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.2.3", "net8.0", [(null, [("Transitive.Dependency", "4.5.6")])]),
1334
+ MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "0.1.2", "net8.0"),
1335
+ ],
1336
+ experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true },
1337
+ workspacePath: "",
1338
+ files: [
1339
+ ("project.csproj", """
1340
+ <Project Sdk="Microsoft.NET.Sdk">
1341
+ <PropertyGroup>
1342
+ <TargetFramework>net8.0</TargetFramework>
1343
+ </PropertyGroup>
1344
+ <ItemGroup>
1345
+ <PackageReference Include="Some.Package" Version="1.2.3" />
1346
+ </ItemGroup>
1347
+ </Project>
1348
+ """)
1349
+ ],
1350
+ expectedResult: new()
1351
+ {
1352
+ Path = "",
1353
+ Projects = [],
1354
+ Error = new DependencyNotFound("Transitive.Dependency"),
1355
+ }
1356
+ );
1357
+ }
1297
1358
  }
@@ -620,6 +620,14 @@ public class SerializationTests
620
620
  """
621
621
  ];
622
622
 
623
+ yield return
624
+ [
625
+ new DependencyNotFound("some source"),
626
+ """
627
+ {"data":{"error-type":"dependency_not_found","error-details":{"source":"some source"}}}
628
+ """
629
+ ];
630
+
623
631
  yield return
624
632
  [
625
633
  new JobRepoNotFound("some message"),
@@ -2632,7 +2632,7 @@ public partial class UpdateWorkerTests
2632
2632
  """,
2633
2633
  expectedResult: new()
2634
2634
  {
2635
- Error = new UpdateNotPossible(["Unrelated.Package.1.0.0"]),
2635
+ Error = new DependencyNotFound("Unrelated.Package.1.0.0"),
2636
2636
  }
2637
2637
  );
2638
2638
  }
@@ -1521,9 +1521,25 @@ public class MSBuildHelperTests : TestBase
1521
1521
  yield return
1522
1522
  [
1523
1523
  // output
1524
- "Package 'Some.Package' is not found on source",
1524
+ "Package 'Some.Package' is not found on source 'some-source'.",
1525
1525
  // expectedError
1526
- new UpdateNotPossible(["Some.Package"]),
1526
+ new DependencyNotFound("Some.Package"),
1527
+ ];
1528
+
1529
+ yield return
1530
+ [
1531
+ // output
1532
+ "error NU1101: Unable to find package Some.Package. No packages exist with this id in source(s): some-source",
1533
+ // expectedError
1534
+ new DependencyNotFound("Some.Package"),
1535
+ ];
1536
+
1537
+ yield return
1538
+ [
1539
+ // output
1540
+ "Unable to find package Some.Package with version (= 1.2.3)",
1541
+ // expectedError
1542
+ new DependencyNotFound("Some.Package"),
1527
1543
  ];
1528
1544
 
1529
1545
  yield return
@@ -325,6 +325,9 @@ module Dependabot
325
325
  file_path = T.let(error_details.fetch("file-path"), String)
326
326
  message = T.let(error_details.fetch("message", nil), T.nilable(String))
327
327
  raise DependencyFileNotParseable.new(file_path, message)
328
+ when "dependency_not_found"
329
+ source = T.let(error_details.fetch("source"), String)
330
+ raise DependencyNotFound, source
328
331
  when "illformed_requirement"
329
332
  raise BadRequirementError, T.let(error_details.fetch("message"), String)
330
333
  when "private_source_authentication_failure"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.297.1
4
+ version: 0.297.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.297.1
19
+ version: 0.297.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.297.1
26
+ version: 0.297.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubyzip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -402,6 +402,7 @@ files:
402
402
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Dependency.cs
403
403
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.props
404
404
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.targets
405
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyNotFoundException.cs
405
406
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyType.cs
406
407
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs
407
408
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs
@@ -446,6 +447,7 @@ files:
446
447
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyFileNotFound.cs
447
448
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyFileNotParseable.cs
448
449
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyGroup.cs
450
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyNotFound.cs
449
451
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/GroupPullRequest.cs
450
452
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/IncrementMetric.cs
451
453
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs
@@ -533,7 +535,7 @@ licenses:
533
535
  - MIT
534
536
  metadata:
535
537
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
536
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.297.1
538
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.297.2
537
539
  post_install_message:
538
540
  rdoc_options: []
539
541
  require_paths: