dependabot-nuget 0.403.0 → 0.404.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: 70b41cf5ca1d42b9d660ec764608de4bc6810788b05b0f2e9d6c03eefd90f277
4
- data.tar.gz: c437530231b3a4991a98d6f9f6783b45f97e40529610676a920a19258f92ceca
3
+ metadata.gz: def91d11e5d6c2dc8574fb7dc559e89e6a1a5d0e6f005ec8825c7cd9357772ac
4
+ data.tar.gz: cea0054ad998339589f1c9b8a55430b1753adb4f96e1cba0f41c0040a3046d29
5
5
  SHA512:
6
- metadata.gz: 3959f15dd5206ef05509dbf432ce41fdcf9a73fdb9bf49872d0f251368bb958a46a3687c18050ce1d26dc848de5b583a6d46853eb1190a3b6476ac700fa4f62c
7
- data.tar.gz: f49fa46553521a7bc9635ba0df71993c4fd677f9527b3c59bf3022813dc99c4d7642515e18971c8ec9fe6842393f3eb87179ca6dcea14364c2246bf5016399a3
6
+ metadata.gz: 06f6fdaa57705064b5b85677ea34dd9429a223264b054e08a0517cbe2ef0c876cff4156c46a728b39bbb7e08e9fcba34eac01629095018010f3783daa8081946
7
+ data.tar.gz: 49f43e6760d0816b034bc6186d69bc7ee9bfa0e572e6bba2b20015bf1b720661e23b89df16b3adcd9e1d95e5f7d7e3fca3998ef7760bac3f654762a075ca2ecb
@@ -329,15 +329,20 @@ internal static class VersionFinder
329
329
  var isMajorBump = version.Major > currentVersion.Major;
330
330
  var isMinorBump = version.Major == currentVersion.Major && version.Minor > currentVersion.Minor;
331
331
  var isPatchBump = version.Major == currentVersion.Major && version.Minor == currentVersion.Minor && version.Patch > currentVersion.Patch;
332
+
333
+ // each ignored update type only rejects bumps of exactly that type, e.g., ignoring `semver-patch`
334
+ // still allows minor and major bumps; this matches the ignore ranges of the other ecosystems and is
335
+ // required for groups, whose `update-types` are forwarded as the ignored complement (a group with
336
+ // `update-types: [major]` ignores `semver-minor` and `semver-patch`, but must still find major bumps)
332
337
  foreach (var ignoreType in dependencyInfo.IgnoredUpdateTypes)
333
338
  {
334
339
  switch (ignoreType)
335
340
  {
336
341
  case ConditionUpdateType.SemVerPatch:
337
- isIgnoredByType = isIgnoredByType || isPatchBump || isMinorBump || isMajorBump;
342
+ isIgnoredByType = isIgnoredByType || isPatchBump;
338
343
  break;
339
344
  case ConditionUpdateType.SemVerMinor:
340
- isIgnoredByType = isIgnoredByType || isMinorBump || isMajorBump;
345
+ isIgnoredByType = isIgnoredByType || isMinorBump;
341
346
  break;
342
347
  case ConditionUpdateType.SemVerMajor:
343
348
  isIgnoredByType = isIgnoredByType || isMajorBump;
@@ -31,6 +31,10 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
31
31
  var repoContentsPath = caseInsensitiveRepoContentsPath ?? originalRepoContentsPath;
32
32
  var jobDependencies = job.Dependencies.ToHashSet(StringComparer.OrdinalIgnoreCase);
33
33
  var initialFiles = ModifiedFilesTracker.GetInitiallyExistingFiles(repoContentsPath);
34
+ // directories share a working tree, so an earlier directory may already have updated (or created) the PR
35
+ var pullRequestUpdated = false;
36
+ // closing is deferred until every directory has been evaluated so the outcome doesn't depend on directory order
37
+ ClosePullRequest? pendingClose = null;
34
38
  foreach (var directory in job.GetAllDirectories(repoContentsPath.FullName))
35
39
  {
36
40
  var discoveryResult = await discoveryWorker.RunAsync(repoContentsPath.FullName, directory);
@@ -59,8 +63,7 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
59
63
  if (groupedUpdateOperationsToPerform.Count == 0)
60
64
  {
61
65
  var close = ClosePullRequest.WithDependenciesRemoved(job);
62
- logger.Info(close.GetReport());
63
- await apiHandler.ClosePullRequest(close);
66
+ pendingClose ??= close;
64
67
  continue;
65
68
  }
66
69
 
@@ -71,11 +74,11 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
71
74
  if (missingDependencies.Length > 0)
72
75
  {
73
76
  var close = ClosePullRequest.WithDependencyRemoved(job);
74
- logger.Info(close.GetReport());
75
- await apiHandler.ClosePullRequest(close);
77
+ pendingClose ??= close;
76
78
  continue;
77
79
  }
78
80
 
81
+ var noVulnerableDependencies = false;
79
82
  var tracker = new ModifiedFilesTracker(originalRepoContentsPath, initialFiles, logger);
80
83
  await tracker.StartTrackingAsync(discoveryResult);
81
84
  foreach (var dependencyGroupToUpdate in groupedUpdateOperationsToPerform)
@@ -90,9 +93,9 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
90
93
  if (vulnerableDependenciesToUpdate.Length == 0)
91
94
  {
92
95
  var close = ClosePullRequest.WithUpToDate(job);
93
- logger.Info(close.GetReport());
94
- await apiHandler.ClosePullRequest(close);
95
- return;
96
+ pendingClose ??= close;
97
+ noVulnerableDependencies = true;
98
+ break;
96
99
  }
97
100
 
98
101
  foreach (var (projectPath, dependency, dependencyInfo) in vulnerableDependenciesToUpdate)
@@ -141,6 +144,11 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
141
144
  }
142
145
  }
143
146
 
147
+ if (noVulnerableDependencies)
148
+ {
149
+ continue;
150
+ }
151
+
144
152
  // ensure we did something
145
153
  var updatesNotPerformed = jobDependencies
146
154
  .Except(updatedDependencies.Select(d => d.Name), StringComparer.OrdinalIgnoreCase)
@@ -151,7 +159,7 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
151
159
  if (updatesNotPerformed.Length > 0)
152
160
  {
153
161
  logger.Info($"No updates performed for: {string.Join(", ", updatesNotPerformed)}");
154
- await apiHandler.ClosePullRequest(ClosePullRequest.WithUpdateNoLongerPossible(job));
162
+ pendingClose ??= ClosePullRequest.WithUpdateNoLongerPossible(job);
155
163
  continue;
156
164
  }
157
165
 
@@ -178,6 +186,7 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
178
186
  PrTitle = prTitle,
179
187
  PrBody = prBody,
180
188
  });
189
+ pullRequestUpdated = true;
181
190
  continue;
182
191
  }
183
192
  else
@@ -198,9 +207,16 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
198
207
  PrBody = prBody,
199
208
  DependencyGroup = null,
200
209
  });
210
+ pullRequestUpdated = true;
201
211
  continue;
202
212
  }
203
213
  }
204
214
  }
215
+
216
+ if (!pullRequestUpdated && pendingClose is not null)
217
+ {
218
+ logger.Info(pendingClose.GetReport());
219
+ await apiHandler.ClosePullRequest(pendingClose);
220
+ }
205
221
  }
206
222
  }
@@ -31,6 +31,10 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
31
31
  var repoContentsPath = caseInsensitiveRepoContentsPath ?? originalRepoContentsPath;
32
32
  var jobDependencies = job.Dependencies.ToHashSet(StringComparer.OrdinalIgnoreCase);
33
33
  var initialFiles = ModifiedFilesTracker.GetInitiallyExistingFiles(repoContentsPath);
34
+ // directories share a working tree, so an earlier directory may already have updated (or created) the PR
35
+ var pullRequestUpdated = false;
36
+ // closing is deferred until every directory has been evaluated so the outcome doesn't depend on directory order
37
+ ClosePullRequest? pendingClose = null;
34
38
  foreach (var directory in job.GetAllDirectories(repoContentsPath.FullName))
35
39
  {
36
40
  var discoveryResult = await discoveryWorker.RunAsync(repoContentsPath.FullName, directory);
@@ -56,8 +60,7 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
56
60
  if (relevantUpdateOperationsToPerform.Count == 0)
57
61
  {
58
62
  var close = ClosePullRequest.WithDependenciesRemoved(job);
59
- logger.Info(close.GetReport());
60
- await apiHandler.ClosePullRequest(close);
63
+ pendingClose ??= close;
61
64
  continue;
62
65
  }
63
66
 
@@ -68,8 +71,7 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
68
71
  if (missingDependencies.Length > 0)
69
72
  {
70
73
  var close = ClosePullRequest.WithDependencyRemoved(job);
71
- logger.Info(close.GetReport());
72
- await apiHandler.ClosePullRequest(close);
74
+ pendingClose ??= close;
73
75
  continue;
74
76
  }
75
77
 
@@ -141,7 +143,7 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
141
143
  if (updatesNotPerformed.Length > 0)
142
144
  {
143
145
  logger.Info($"No updates performed for: {string.Join(", ", updatesNotPerformed)}");
144
- await apiHandler.ClosePullRequest(ClosePullRequest.WithUpdateNoLongerPossible(job));
146
+ pendingClose ??= ClosePullRequest.WithUpdateNoLongerPossible(job);
145
147
  continue;
146
148
  }
147
149
 
@@ -168,6 +170,7 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
168
170
  PrTitle = prTitle,
169
171
  PrBody = prBody,
170
172
  });
173
+ pullRequestUpdated = true;
171
174
  continue;
172
175
  }
173
176
  else
@@ -188,9 +191,16 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
188
191
  PrBody = prBody,
189
192
  DependencyGroup = null,
190
193
  });
194
+ pullRequestUpdated = true;
191
195
  continue;
192
196
  }
193
197
  }
194
198
  }
199
+
200
+ if (!pullRequestUpdated && pendingClose is not null)
201
+ {
202
+ logger.Info(pendingClose.GetReport());
203
+ await apiHandler.ClosePullRequest(pendingClose);
204
+ }
195
205
  }
196
206
  }
@@ -341,11 +341,16 @@ public class VersionFinderTests : TestBase
341
341
  }
342
342
 
343
343
  [Theory]
344
- [InlineData(null, "1.0.1", "1.1.0", "2.0.0")]
345
- [InlineData(ConditionUpdateType.SemVerMajor, "1.0.1", "1.1.0")]
346
- [InlineData(ConditionUpdateType.SemVerMinor, "1.0.1")]
347
- [InlineData(ConditionUpdateType.SemVerPatch)]
348
- public async Task VersionFinder_IgnoredUpdateTypesIsHonored(ConditionUpdateType? ignoredUpdateType, params string[] expectedVersions)
344
+ [InlineData(new ConditionUpdateType[0], new[] { "1.0.1", "1.1.0", "2.0.0" })]
345
+ [InlineData(new[] { ConditionUpdateType.SemVerMajor }, new[] { "1.0.1", "1.1.0" })]
346
+ [InlineData(new[] { ConditionUpdateType.SemVerMinor }, new[] { "1.0.1", "2.0.0" })]
347
+ [InlineData(new[] { ConditionUpdateType.SemVerPatch }, new[] { "1.1.0", "2.0.0" })]
348
+ [InlineData(new[] { ConditionUpdateType.SemVerMajor, ConditionUpdateType.SemVerMinor }, new[] { "1.0.1" })]
349
+ [InlineData(new[] { ConditionUpdateType.SemVerMajor, ConditionUpdateType.SemVerPatch }, new[] { "1.1.0" })]
350
+ // this is what a group with `update-types: [major]` forwards
351
+ [InlineData(new[] { ConditionUpdateType.SemVerMinor, ConditionUpdateType.SemVerPatch }, new[] { "2.0.0" })]
352
+ [InlineData(new[] { ConditionUpdateType.SemVerMajor, ConditionUpdateType.SemVerMinor, ConditionUpdateType.SemVerPatch }, new string[0])]
353
+ public async Task VersionFinder_IgnoredUpdateTypesIsHonored(ConditionUpdateType[] ignoredUpdateTypes, string[] expectedVersions)
349
354
  {
350
355
  // arrange
351
356
  using var tempDir = new TemporaryDirectory();
@@ -355,9 +360,6 @@ public class VersionFinderTests : TestBase
355
360
  MockNuGetPackage.CreateSimplePackage("Some.Dependency", "2.0.0", "net9.0"),
356
361
  ], tempDir.DirectoryPath);
357
362
  var tfm = NuGetFramework.Parse("net9.0");
358
- var ignoredUpdateTypes = ignoredUpdateType is not null
359
- ? new ConditionUpdateType[] { ignoredUpdateType.Value }
360
- : [];
361
363
  var dependencyInfo = new DependencyInfo()
362
364
  {
363
365
  Name = "Some.Dependency",
@@ -1245,5 +1245,38 @@ public class MiscellaneousTests
1245
1245
  IgnoredUpdateTypes = [ConditionUpdateType.SemVerMajor, ConditionUpdateType.SemVerMinor],
1246
1246
  },
1247
1247
  ];
1248
+
1249
+ // with limited group update types; only major is explicitly allowed => minor and patch are ignored
1250
+ yield return
1251
+ [
1252
+ // job
1253
+ new Job()
1254
+ {
1255
+ Source = new()
1256
+ {
1257
+ Provider = "github",
1258
+ Repo = "some/repo"
1259
+ },
1260
+ },
1261
+ // dependency
1262
+ new Dependency("Some.Dependency", "1.0.0", DependencyType.PackageReference),
1263
+ // groupMatcher
1264
+ new GroupMatcher()
1265
+ {
1266
+ Patterns = ["Some.*"],
1267
+ ExcludePatterns = [],
1268
+ UpdateTypes = [GroupUpdateType.Major],
1269
+ },
1270
+ // expectedDependencyInfo
1271
+ new DependencyInfo()
1272
+ {
1273
+ Name = "Some.Dependency",
1274
+ Version = "1.0.0",
1275
+ IsVulnerable = false,
1276
+ IgnoredVersions = [],
1277
+ Vulnerabilities = [],
1278
+ IgnoredUpdateTypes = [ConditionUpdateType.SemVerMinor, ConditionUpdateType.SemVerPatch],
1279
+ },
1280
+ ];
1248
1281
  }
1249
1282
  }
@@ -961,6 +961,284 @@ public class RefreshSecurityUpdatePullRequestHandlerTests : UpdateHandlersTestsB
961
961
  );
962
962
  }
963
963
 
964
+ [Fact]
965
+ public async Task DoesNotClosePullRequest_WhenEarlierDirectoryAlreadyUpdatedIt()
966
+ {
967
+ await TestAsync(
968
+ job: new Job()
969
+ {
970
+ Dependencies = ["Some.Dependency"],
971
+ ExistingPullRequests = [new() { Dependencies = [new() { DependencyName = "Some.Dependency", DependencyVersion = NuGetVersion.Parse("2.0.0") }] }],
972
+ Source = CreateJobSource("/src", "/tests"),
973
+ SecurityAdvisories = [new() { DependencyName = "Some.Dependency", AffectedVersions = [Requirement.Parse("= 1.0.0")], PatchedVersions = [Requirement.Parse("2.0.0")] }],
974
+ SecurityUpdatesOnly = true,
975
+ UpdatingAPullRequest = true,
976
+ },
977
+ files: [
978
+ ("src/project.csproj", "initial contents"),
979
+ ("tests/tests.csproj", "initial contents"),
980
+ ],
981
+ discoveryWorker: TestDiscoveryWorker.FromResults(
982
+ ("/src", new WorkspaceDiscoveryResult()
983
+ {
984
+ Path = "/src",
985
+ Projects = [
986
+ new()
987
+ {
988
+ FilePath = "project.csproj",
989
+ Dependencies = [
990
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
991
+ ],
992
+ ImportedFiles = [],
993
+ AdditionalFiles = [],
994
+ }
995
+ ],
996
+ }),
997
+ ("/tests", new WorkspaceDiscoveryResult()
998
+ {
999
+ Path = "/tests",
1000
+ Projects = [
1001
+ new()
1002
+ {
1003
+ FilePath = "tests.csproj",
1004
+ Dependencies = [
1005
+ new("Some.Dependency", "2.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
1006
+ ],
1007
+ ImportedFiles = [],
1008
+ AdditionalFiles = [],
1009
+ }
1010
+ ],
1011
+ })
1012
+ ),
1013
+ analyzeWorker: new TestAnalyzeWorker(input =>
1014
+ {
1015
+ var discovery = input.Item2;
1016
+ return Task.FromResult(new AnalysisResult()
1017
+ {
1018
+ CanUpdate = discovery.Path == "/src",
1019
+ UpdatedVersion = "2.0.0",
1020
+ UpdatedDependencies = [],
1021
+ });
1022
+ }),
1023
+ updaterWorker: new TestUpdaterWorker(async input =>
1024
+ {
1025
+ var repoRoot = input.Item1;
1026
+ var workspacePath = input.Item2;
1027
+
1028
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
1029
+
1030
+ return new UpdateOperationResult()
1031
+ {
1032
+ UpdateOperations = [new DirectUpdate() { DependencyName = "Some.Dependency", NewVersion = NuGetVersion.Parse("2.0.0"), UpdatedFiles = ["/src/project.csproj"] }],
1033
+ };
1034
+ }),
1035
+ expectedUpdateHandler: RefreshSecurityUpdatePullRequestHandler.Instance,
1036
+ expectedApiMessages: [
1037
+ new UpdatedDependencyList()
1038
+ {
1039
+ Dependencies = [
1040
+ new()
1041
+ {
1042
+ Name = "Some.Dependency",
1043
+ Version = "1.0.0",
1044
+ Requirements = [
1045
+ new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
1046
+ ],
1047
+ },
1048
+ ],
1049
+ DependencyFiles = ["/src/project.csproj"],
1050
+ },
1051
+ new IncrementMetric()
1052
+ {
1053
+ Metric = "updater.started",
1054
+ Tags = new()
1055
+ {
1056
+ ["operation"] = "update_security_pr",
1057
+ }
1058
+ },
1059
+ new UpdatePullRequest()
1060
+ {
1061
+ DependencyNames = ["Some.Dependency"],
1062
+ DependencyGroup = null,
1063
+ UpdatedDependencyFiles = [
1064
+ new()
1065
+ {
1066
+ Directory = "/src",
1067
+ Name = "project.csproj",
1068
+ Content = "updated contents",
1069
+ }
1070
+ ],
1071
+ BaseCommitSha = "TEST-COMMIT-SHA",
1072
+ CommitMessage = EndToEndTests.TestPullRequestCommitMessage,
1073
+ PrTitle = EndToEndTests.TestPullRequestTitle,
1074
+ PrBody = EndToEndTests.TestPullRequestBody,
1075
+ },
1076
+ new UpdatedDependencyList()
1077
+ {
1078
+ Dependencies = [
1079
+ new()
1080
+ {
1081
+ Name = "Some.Dependency",
1082
+ Version = "2.0.0",
1083
+ Requirements = [
1084
+ new() { Requirement = "2.0.0", File = "/tests/tests.csproj", Groups = ["dependencies"] },
1085
+ ],
1086
+ },
1087
+ ],
1088
+ DependencyFiles = ["/tests/tests.csproj"],
1089
+ },
1090
+ new IncrementMetric()
1091
+ {
1092
+ Metric = "updater.started",
1093
+ Tags = new()
1094
+ {
1095
+ ["operation"] = "update_security_pr",
1096
+ }
1097
+ },
1098
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
1099
+ ]
1100
+ );
1101
+ }
1102
+
1103
+ [Fact]
1104
+ public async Task DoesNotClosePullRequest_WhenUpToDateDirectoryIsFollowedByDirectoryNeedingUpdate()
1105
+ {
1106
+ await TestAsync(
1107
+ job: new Job()
1108
+ {
1109
+ Dependencies = ["Some.Dependency"],
1110
+ ExistingPullRequests = [new() { Dependencies = [new() { DependencyName = "Some.Dependency", DependencyVersion = NuGetVersion.Parse("2.0.0") }] }],
1111
+ Source = CreateJobSource("/tests", "/src"),
1112
+ SecurityAdvisories = [new() { DependencyName = "Some.Dependency", AffectedVersions = [Requirement.Parse("= 1.0.0")], PatchedVersions = [Requirement.Parse("2.0.0")] }],
1113
+ SecurityUpdatesOnly = true,
1114
+ UpdatingAPullRequest = true,
1115
+ },
1116
+ files: [
1117
+ ("src/project.csproj", "initial contents"),
1118
+ ("tests/tests.csproj", "initial contents"),
1119
+ ],
1120
+ discoveryWorker: TestDiscoveryWorker.FromResults(
1121
+ ("/src", new WorkspaceDiscoveryResult()
1122
+ {
1123
+ Path = "/src",
1124
+ Projects = [
1125
+ new()
1126
+ {
1127
+ FilePath = "project.csproj",
1128
+ Dependencies = [
1129
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
1130
+ ],
1131
+ ImportedFiles = [],
1132
+ AdditionalFiles = [],
1133
+ }
1134
+ ],
1135
+ }),
1136
+ ("/tests", new WorkspaceDiscoveryResult()
1137
+ {
1138
+ Path = "/tests",
1139
+ Projects = [
1140
+ new()
1141
+ {
1142
+ FilePath = "tests.csproj",
1143
+ Dependencies = [
1144
+ new("Some.Dependency", "2.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
1145
+ ],
1146
+ ImportedFiles = [],
1147
+ AdditionalFiles = [],
1148
+ }
1149
+ ],
1150
+ })
1151
+ ),
1152
+ analyzeWorker: new TestAnalyzeWorker(input =>
1153
+ {
1154
+ var discovery = input.Item2;
1155
+ return Task.FromResult(new AnalysisResult()
1156
+ {
1157
+ CanUpdate = discovery.Path == "/src",
1158
+ UpdatedVersion = "2.0.0",
1159
+ UpdatedDependencies = [],
1160
+ });
1161
+ }),
1162
+ updaterWorker: new TestUpdaterWorker(async input =>
1163
+ {
1164
+ var repoRoot = input.Item1;
1165
+ var workspacePath = input.Item2;
1166
+
1167
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
1168
+
1169
+ return new UpdateOperationResult()
1170
+ {
1171
+ UpdateOperations = [new DirectUpdate() { DependencyName = "Some.Dependency", NewVersion = NuGetVersion.Parse("2.0.0"), UpdatedFiles = ["/src/project.csproj"] }],
1172
+ };
1173
+ }),
1174
+ expectedUpdateHandler: RefreshSecurityUpdatePullRequestHandler.Instance,
1175
+ expectedApiMessages: [
1176
+ new UpdatedDependencyList()
1177
+ {
1178
+ Dependencies = [
1179
+ new()
1180
+ {
1181
+ Name = "Some.Dependency",
1182
+ Version = "2.0.0",
1183
+ Requirements = [
1184
+ new() { Requirement = "2.0.0", File = "/tests/tests.csproj", Groups = ["dependencies"] },
1185
+ ],
1186
+ },
1187
+ ],
1188
+ DependencyFiles = ["/tests/tests.csproj"],
1189
+ },
1190
+ new IncrementMetric()
1191
+ {
1192
+ Metric = "updater.started",
1193
+ Tags = new()
1194
+ {
1195
+ ["operation"] = "update_security_pr",
1196
+ }
1197
+ },
1198
+ new UpdatedDependencyList()
1199
+ {
1200
+ Dependencies = [
1201
+ new()
1202
+ {
1203
+ Name = "Some.Dependency",
1204
+ Version = "1.0.0",
1205
+ Requirements = [
1206
+ new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
1207
+ ],
1208
+ },
1209
+ ],
1210
+ DependencyFiles = ["/src/project.csproj"],
1211
+ },
1212
+ new IncrementMetric()
1213
+ {
1214
+ Metric = "updater.started",
1215
+ Tags = new()
1216
+ {
1217
+ ["operation"] = "update_security_pr",
1218
+ }
1219
+ },
1220
+ new UpdatePullRequest()
1221
+ {
1222
+ DependencyNames = ["Some.Dependency"],
1223
+ DependencyGroup = null,
1224
+ UpdatedDependencyFiles = [
1225
+ new()
1226
+ {
1227
+ Directory = "/src",
1228
+ Name = "project.csproj",
1229
+ Content = "updated contents",
1230
+ }
1231
+ ],
1232
+ BaseCommitSha = "TEST-COMMIT-SHA",
1233
+ CommitMessage = EndToEndTests.TestPullRequestCommitMessage,
1234
+ PrTitle = EndToEndTests.TestPullRequestTitle,
1235
+ PrBody = EndToEndTests.TestPullRequestBody,
1236
+ },
1237
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
1238
+ ]
1239
+ );
1240
+ }
1241
+
964
1242
  [Fact]
965
1243
  public async Task RecreatesPullRequest()
966
1244
  {
@@ -647,6 +647,280 @@ public class RefreshVersionUpdatePullRequestHandlerTests : UpdateHandlersTestsBa
647
647
  );
648
648
  }
649
649
 
650
+ [Fact]
651
+ public async Task DoesNotClosePullRequest_WhenEarlierDirectoryAlreadyUpdatedIt()
652
+ {
653
+ await TestAsync(
654
+ job: new Job()
655
+ {
656
+ Dependencies = ["Some.Dependency"],
657
+ ExistingPullRequests = [new() { Dependencies = [new() { DependencyName = "Some.Dependency", DependencyVersion = NuGetVersion.Parse("2.0.0") }] }],
658
+ Source = CreateJobSource("/src", "/tests"),
659
+ UpdatingAPullRequest = true,
660
+ },
661
+ files: [
662
+ ("src/project.csproj", "initial contents"),
663
+ ("tests/tests.csproj", "initial contents"),
664
+ ],
665
+ discoveryWorker: TestDiscoveryWorker.FromResults(
666
+ ("/src", new WorkspaceDiscoveryResult()
667
+ {
668
+ Path = "/src",
669
+ Projects = [
670
+ new()
671
+ {
672
+ FilePath = "project.csproj",
673
+ Dependencies = [
674
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
675
+ ],
676
+ ImportedFiles = [],
677
+ AdditionalFiles = [],
678
+ }
679
+ ],
680
+ }),
681
+ ("/tests", new WorkspaceDiscoveryResult()
682
+ {
683
+ Path = "/tests",
684
+ Projects = [
685
+ new()
686
+ {
687
+ FilePath = "tests.csproj",
688
+ Dependencies = [
689
+ new("Some.Dependency", "2.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
690
+ ],
691
+ ImportedFiles = [],
692
+ AdditionalFiles = [],
693
+ }
694
+ ],
695
+ })
696
+ ),
697
+ analyzeWorker: new TestAnalyzeWorker(input =>
698
+ {
699
+ var discovery = input.Item2;
700
+ return Task.FromResult(new AnalysisResult()
701
+ {
702
+ CanUpdate = discovery.Path == "/src",
703
+ UpdatedVersion = "2.0.0",
704
+ UpdatedDependencies = [],
705
+ });
706
+ }),
707
+ updaterWorker: new TestUpdaterWorker(async input =>
708
+ {
709
+ var repoRoot = input.Item1;
710
+ var workspacePath = input.Item2;
711
+
712
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
713
+
714
+ return new UpdateOperationResult()
715
+ {
716
+ UpdateOperations = [new DirectUpdate() { DependencyName = "Some.Dependency", NewVersion = NuGetVersion.Parse("2.0.0"), UpdatedFiles = ["/src/project.csproj"] }],
717
+ };
718
+ }),
719
+ expectedUpdateHandler: RefreshVersionUpdatePullRequestHandler.Instance,
720
+ expectedApiMessages: [
721
+ new UpdatedDependencyList()
722
+ {
723
+ Dependencies = [
724
+ new()
725
+ {
726
+ Name = "Some.Dependency",
727
+ Version = "1.0.0",
728
+ Requirements = [
729
+ new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
730
+ ],
731
+ },
732
+ ],
733
+ DependencyFiles = ["/src/project.csproj"],
734
+ },
735
+ new IncrementMetric()
736
+ {
737
+ Metric = "updater.started",
738
+ Tags = new()
739
+ {
740
+ ["operation"] = "update_version_pr",
741
+ }
742
+ },
743
+ new UpdatePullRequest()
744
+ {
745
+ DependencyNames = ["Some.Dependency"],
746
+ DependencyGroup = null,
747
+ UpdatedDependencyFiles = [
748
+ new()
749
+ {
750
+ Directory = "/src",
751
+ Name = "project.csproj",
752
+ Content = "updated contents",
753
+ }
754
+ ],
755
+ BaseCommitSha = "TEST-COMMIT-SHA",
756
+ CommitMessage = EndToEndTests.TestPullRequestCommitMessage,
757
+ PrTitle = EndToEndTests.TestPullRequestTitle,
758
+ PrBody = EndToEndTests.TestPullRequestBody,
759
+ },
760
+ new UpdatedDependencyList()
761
+ {
762
+ Dependencies = [
763
+ new()
764
+ {
765
+ Name = "Some.Dependency",
766
+ Version = "2.0.0",
767
+ Requirements = [
768
+ new() { Requirement = "2.0.0", File = "/tests/tests.csproj", Groups = ["dependencies"] },
769
+ ],
770
+ },
771
+ ],
772
+ DependencyFiles = ["/tests/tests.csproj"],
773
+ },
774
+ new IncrementMetric()
775
+ {
776
+ Metric = "updater.started",
777
+ Tags = new()
778
+ {
779
+ ["operation"] = "update_version_pr",
780
+ }
781
+ },
782
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
783
+ ]
784
+ );
785
+ }
786
+
787
+ [Fact]
788
+ public async Task DoesNotClosePullRequest_WhenLaterDirectoryUpdatesIt()
789
+ {
790
+ await TestAsync(
791
+ job: new Job()
792
+ {
793
+ Dependencies = ["Some.Dependency"],
794
+ ExistingPullRequests = [new() { Dependencies = [new() { DependencyName = "Some.Dependency", DependencyVersion = NuGetVersion.Parse("2.0.0") }] }],
795
+ Source = CreateJobSource("/tests", "/src"),
796
+ UpdatingAPullRequest = true,
797
+ },
798
+ files: [
799
+ ("src/project.csproj", "initial contents"),
800
+ ("tests/tests.csproj", "initial contents"),
801
+ ],
802
+ discoveryWorker: TestDiscoveryWorker.FromResults(
803
+ ("/src", new WorkspaceDiscoveryResult()
804
+ {
805
+ Path = "/src",
806
+ Projects = [
807
+ new()
808
+ {
809
+ FilePath = "project.csproj",
810
+ Dependencies = [
811
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
812
+ ],
813
+ ImportedFiles = [],
814
+ AdditionalFiles = [],
815
+ }
816
+ ],
817
+ }),
818
+ ("/tests", new WorkspaceDiscoveryResult()
819
+ {
820
+ Path = "/tests",
821
+ Projects = [
822
+ new()
823
+ {
824
+ FilePath = "tests.csproj",
825
+ Dependencies = [
826
+ new("Some.Dependency", "2.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
827
+ ],
828
+ ImportedFiles = [],
829
+ AdditionalFiles = [],
830
+ }
831
+ ],
832
+ })
833
+ ),
834
+ analyzeWorker: new TestAnalyzeWorker(input =>
835
+ {
836
+ var discovery = input.Item2;
837
+ return Task.FromResult(new AnalysisResult()
838
+ {
839
+ CanUpdate = discovery.Path == "/src",
840
+ UpdatedVersion = "2.0.0",
841
+ UpdatedDependencies = [],
842
+ });
843
+ }),
844
+ updaterWorker: new TestUpdaterWorker(async input =>
845
+ {
846
+ var repoRoot = input.Item1;
847
+ var workspacePath = input.Item2;
848
+
849
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
850
+
851
+ return new UpdateOperationResult()
852
+ {
853
+ UpdateOperations = [new DirectUpdate() { DependencyName = "Some.Dependency", NewVersion = NuGetVersion.Parse("2.0.0"), UpdatedFiles = ["/src/project.csproj"] }],
854
+ };
855
+ }),
856
+ expectedUpdateHandler: RefreshVersionUpdatePullRequestHandler.Instance,
857
+ expectedApiMessages: [
858
+ new UpdatedDependencyList()
859
+ {
860
+ Dependencies = [
861
+ new()
862
+ {
863
+ Name = "Some.Dependency",
864
+ Version = "2.0.0",
865
+ Requirements = [
866
+ new() { Requirement = "2.0.0", File = "/tests/tests.csproj", Groups = ["dependencies"] },
867
+ ],
868
+ },
869
+ ],
870
+ DependencyFiles = ["/tests/tests.csproj"],
871
+ },
872
+ new IncrementMetric()
873
+ {
874
+ Metric = "updater.started",
875
+ Tags = new()
876
+ {
877
+ ["operation"] = "update_version_pr",
878
+ }
879
+ },
880
+ new UpdatedDependencyList()
881
+ {
882
+ Dependencies = [
883
+ new()
884
+ {
885
+ Name = "Some.Dependency",
886
+ Version = "1.0.0",
887
+ Requirements = [
888
+ new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
889
+ ],
890
+ },
891
+ ],
892
+ DependencyFiles = ["/src/project.csproj"],
893
+ },
894
+ new IncrementMetric()
895
+ {
896
+ Metric = "updater.started",
897
+ Tags = new()
898
+ {
899
+ ["operation"] = "update_version_pr",
900
+ }
901
+ },
902
+ new UpdatePullRequest()
903
+ {
904
+ DependencyNames = ["Some.Dependency"],
905
+ DependencyGroup = null,
906
+ UpdatedDependencyFiles = [
907
+ new()
908
+ {
909
+ Directory = "/src",
910
+ Name = "project.csproj",
911
+ Content = "updated contents",
912
+ }
913
+ ],
914
+ BaseCommitSha = "TEST-COMMIT-SHA",
915
+ CommitMessage = EndToEndTests.TestPullRequestCommitMessage,
916
+ PrTitle = EndToEndTests.TestPullRequestTitle,
917
+ PrBody = EndToEndTests.TestPullRequestBody,
918
+ },
919
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
920
+ ]
921
+ );
922
+ }
923
+
650
924
  [Fact]
651
925
  public async Task RecreatesPullRequest()
652
926
  {
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.403.0
4
+ version: 0.404.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.403.0
18
+ version: 0.404.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.403.0
25
+ version: 0.404.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -592,7 +592,7 @@ licenses:
592
592
  - MIT
593
593
  metadata:
594
594
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
595
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.403.0
595
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.404.0
596
596
  rdoc_options: []
597
597
  require_paths:
598
598
  - lib