dependabot-nuget 0.369.0 → 0.370.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c69daba9caa7c5be1ee39fa7454b232d79aaf70394a4c2eec181366e0479dc13
4
- data.tar.gz: a75674364b9ed467d976022a40838fd3cf412f804af8ce1dd73e0f564fe0fca8
3
+ metadata.gz: a443457e2e8e24c70f4cb8a9e11a2fff6c3f9d15255b7e023c29a1ccdf4bd548
4
+ data.tar.gz: 272f36da3e3a53a28cd748d21da99bf8b5c94ca94c854e549db6dc1ee8b2f40a
5
5
  SHA512:
6
- metadata.gz: ee6ac6119b759938fde039435263620115fa9364cc17fb9c48ec42aec11312d4206a70c1b81e35cbc5e82bd2b6956435177b0658e860d0324a43e72b29b5f010
7
- data.tar.gz: ed556d26ad7a22992e30a80b3e2c844add33a65ee501158f9ec741e04924edd7ada871513854b64527fdab13969865605b0a7a3b58592cecafc302522be13cdf
6
+ metadata.gz: 7e5806e6b08c76324c6ba174c1f0a4e085ab62ef8f6694b365932beefa770ea5cdcdf578574f73e61f3b08b1ff7fd2523fa7f23a9598a34f69ccf1f236397b44
7
+ data.tar.gz: 7786d4b33b44eb4fe14cc7ba98d77c5ad45c9213ae80320d895de61db18e19592b72243c3a25b4bcdc182dbdb0f6e2787812b14dd8cf49c606503053c3612a3b
@@ -44,9 +44,14 @@ public class GroupMatcher
44
44
 
45
45
  public bool IsAllowedByVersion(NuGetVersion oldVersion, NuGetVersion newVersion)
46
46
  {
47
+ if (newVersion <= oldVersion)
48
+ {
49
+ return false;
50
+ }
51
+
47
52
  var isMajorBump = newVersion.Major > oldVersion.Major;
48
53
  var isMinorBump = newVersion.Major == oldVersion.Major && newVersion.Minor > oldVersion.Minor;
49
- var isPatchBump = newVersion.Major == oldVersion.Major && newVersion.Minor == oldVersion.Minor && newVersion.Patch > oldVersion.Patch;
54
+ var isPatchEquivalentBump = newVersion.Major == oldVersion.Major && newVersion.Minor == oldVersion.Minor;
50
55
 
51
56
  var allowedUpdateTypes = new HashSet<GroupUpdateType>(UpdateTypes);
52
57
 
@@ -60,7 +65,7 @@ public class GroupMatcher
60
65
  return true;
61
66
  }
62
67
 
63
- if (isPatchBump && allowedUpdateTypes.Contains(GroupUpdateType.Patch))
68
+ if (isPatchEquivalentBump && allowedUpdateTypes.Contains(GroupUpdateType.Patch))
64
69
  {
65
70
  return true;
66
71
  }
@@ -265,6 +265,54 @@ public class MiscellaneousTests
265
265
  ];
266
266
  }
267
267
 
268
+ [Theory]
269
+ [MemberData(nameof(GroupMatcher_IsAllowedByVersionTestData))]
270
+ public void GroupMatcher_IsAllowedByVersion(string[]? updateTypes, string oldVersion, string newVersion, bool expectedAllowed)
271
+ {
272
+ var rules = new Dictionary<string, object>();
273
+ if (updateTypes is not null)
274
+ {
275
+ rules["update-types"] = updateTypes;
276
+ }
277
+
278
+ var group = new DependencyGroup()
279
+ {
280
+ Name = "TestGroup",
281
+ Rules = rules,
282
+ };
283
+
284
+ var matcher = group.GetGroupMatcher();
285
+ var actualAllowed = matcher.IsAllowedByVersion(NuGetVersion.Parse(oldVersion), NuGetVersion.Parse(newVersion));
286
+ Assert.Equal(expectedAllowed, actualAllowed);
287
+ }
288
+
289
+ public static IEnumerable<object?[]> GroupMatcher_IsAllowedByVersionTestData()
290
+ {
291
+ // defaults to major, minor, and patch
292
+ yield return [null, "1.0.0", "2.0.0", true];
293
+ yield return [null, "1.0.0", "1.1.0", true];
294
+ yield return [null, "1.0.0", "1.0.1", true];
295
+
296
+ // constrained update type behavior
297
+ yield return [new[] { "major" }, "1.0.0", "2.0.0", true];
298
+ yield return [new[] { "major" }, "1.0.0", "1.1.0", false];
299
+ yield return [new[] { "minor", "patch" }, "1.0.0", "2.0.0", false];
300
+
301
+ // revision-only and prerelease-only updates should be patch-equivalent, but only for upgrades
302
+ yield return [null, "1.0.0.1", "1.0.0.3", true];
303
+ yield return [null, "1.0.0.1", "1.0.0.1", false];
304
+ yield return [null, "1.0.0.3", "1.0.0.1", false];
305
+ yield return [new[] { "patch" }, "1.0.0.1", "1.0.0.3", true];
306
+ yield return [new[] { "patch" }, "1.0.0.1", "1.0.0.1", false];
307
+ yield return [new[] { "patch" }, "1.0.0.3", "1.0.0.1", false];
308
+ yield return [null, "1.0.0-alpha", "1.0.0-beta", true];
309
+ yield return [null, "1.0.0-alpha", "1.0.0-alpha", false];
310
+ yield return [null, "1.0.0-beta", "1.0.0-alpha", false];
311
+ yield return [new[] { "patch" }, "1.0.0-alpha", "1.0.0-beta", true];
312
+ yield return [new[] { "patch" }, "1.0.0-alpha", "1.0.0-alpha", false];
313
+ yield return [new[] { "patch" }, "1.0.0-beta", "1.0.0-alpha", false];
314
+ }
315
+
268
316
  [Theory]
269
317
  [MemberData(nameof(GetMatchingPullRequestTestData))]
270
318
  public void GetMatchingPullRequest(Job job, IEnumerable<Dependency> dependencies, bool considerVersions, string? expectedGroupPrName, string[]? expectedPrDependencyNames)
@@ -1371,6 +1371,146 @@ public class GroupUpdateAllVersionsHandlerTests : UpdateHandlersTestsBase
1371
1371
  );
1372
1372
  }
1373
1373
 
1374
+ [Fact]
1375
+ public async Task RevisionOnlyUpdateIsGroupedWhenUpdateTypesNotSpecified()
1376
+ {
1377
+ await TestAsync(
1378
+ job: new Job()
1379
+ {
1380
+ Source = CreateJobSource("/src"),
1381
+ DependencyGroups = [new()
1382
+ {
1383
+ Name = "test-group",
1384
+ Rules = new()
1385
+ {
1386
+ ["patterns"] = new[] { "Some.Dependency" },
1387
+ },
1388
+ }]
1389
+ },
1390
+ files: [
1391
+ ("src/project.csproj", "initial contents"),
1392
+ ],
1393
+ discoveryWorker: TestDiscoveryWorker.FromResults(
1394
+ ("/src", new WorkspaceDiscoveryResult()
1395
+ {
1396
+ Path = "/src",
1397
+ Projects = [
1398
+ new()
1399
+ {
1400
+ FilePath = "project.csproj",
1401
+ Dependencies = [
1402
+ new("Some.Dependency", "1.0.0.1", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
1403
+ ],
1404
+ ImportedFiles = [],
1405
+ AdditionalFiles = [],
1406
+ }
1407
+ ],
1408
+ })
1409
+ ),
1410
+ analyzeWorker: new TestAnalyzeWorker(input =>
1411
+ {
1412
+ var dependencyInfo = input.Item3;
1413
+ var newVersion = dependencyInfo.Name switch
1414
+ {
1415
+ "Some.Dependency" => "1.0.0.3",
1416
+ _ => throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}"),
1417
+ };
1418
+ return Task.FromResult(new AnalysisResult()
1419
+ {
1420
+ CanUpdate = true,
1421
+ UpdatedVersion = newVersion,
1422
+ UpdatedDependencies = [],
1423
+ });
1424
+ }),
1425
+ updaterWorker: new TestUpdaterWorker(async input =>
1426
+ {
1427
+ var repoRoot = input.Item1;
1428
+ var workspacePath = input.Item2;
1429
+ var dependencyName = input.Item3;
1430
+ var newVersion = input.Item5;
1431
+
1432
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
1433
+
1434
+ return new UpdateOperationResult()
1435
+ {
1436
+ UpdateOperations = [new DirectUpdate() { DependencyName = dependencyName, NewVersion = NuGetVersion.Parse(newVersion), UpdatedFiles = [workspacePath] }],
1437
+ };
1438
+ }),
1439
+ expectedUpdateHandler: GroupUpdateAllVersionsHandler.Instance,
1440
+ expectedApiMessages: [
1441
+ new IncrementMetric()
1442
+ {
1443
+ Metric = "updater.started",
1444
+ Tags = new()
1445
+ {
1446
+ ["operation"] = "group_update_all_versions",
1447
+ }
1448
+ },
1449
+ // grouped check
1450
+ new UpdatedDependencyList()
1451
+ {
1452
+ Dependencies = [
1453
+ new()
1454
+ {
1455
+ Name = "Some.Dependency",
1456
+ Version = "1.0.0.1",
1457
+ Requirements = [
1458
+ new() { Requirement = "1.0.0.1", File = "/src/project.csproj", Groups = ["dependencies"] },
1459
+ ],
1460
+ },
1461
+ ],
1462
+ DependencyFiles = ["/src/project.csproj"],
1463
+ },
1464
+ new CreatePullRequest()
1465
+ {
1466
+ Dependencies = [
1467
+ new()
1468
+ {
1469
+ Name = "Some.Dependency",
1470
+ Version = "1.0.0.3",
1471
+ Requirements = [
1472
+ new() { Requirement = "1.0.0.3", File = "/src/project.csproj", Groups = ["dependencies"], Source = new() { SourceUrl = null } },
1473
+ ],
1474
+ PreviousVersion = "1.0.0.1",
1475
+ PreviousRequirements = [
1476
+ new() { Requirement = "1.0.0.1", File = "/src/project.csproj", Groups = ["dependencies"] },
1477
+ ],
1478
+ },
1479
+ ],
1480
+ UpdatedDependencyFiles = [
1481
+ new()
1482
+ {
1483
+ Directory = "/src",
1484
+ Name = "project.csproj",
1485
+ Content = "updated contents",
1486
+ },
1487
+ ],
1488
+ BaseCommitSha = "TEST-COMMIT-SHA",
1489
+ CommitMessage = EndToEndTests.TestPullRequestCommitMessage,
1490
+ PrTitle = EndToEndTests.TestPullRequestTitle,
1491
+ PrBody = EndToEndTests.TestPullRequestBody,
1492
+ DependencyGroup = "test-group",
1493
+ },
1494
+ // ungrouped check
1495
+ new UpdatedDependencyList()
1496
+ {
1497
+ Dependencies = [
1498
+ new()
1499
+ {
1500
+ Name = "Some.Dependency",
1501
+ Version = "1.0.0.1",
1502
+ Requirements = [
1503
+ new() { Requirement = "1.0.0.1", File = "/src/project.csproj", Groups = ["dependencies"] },
1504
+ ],
1505
+ },
1506
+ ],
1507
+ DependencyFiles = ["/src/project.csproj"],
1508
+ },
1509
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
1510
+ ]
1511
+ );
1512
+ }
1513
+
1374
1514
  [Fact]
1375
1515
  public async Task UngroupedPullRequestCanBeCreatedIfGroupAppliesToNonMatchedTypes()
1376
1516
  {
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.369.0
4
+ version: 0.370.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.369.0
18
+ version: 0.370.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.369.0
25
+ version: 0.370.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -553,7 +553,7 @@ licenses:
553
553
  - MIT
554
554
  metadata:
555
555
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
556
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.369.0
556
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.370.0
557
557
  rdoc_options: []
558
558
  require_paths:
559
559
  - lib