dependabot-nuget 0.316.0 → 0.317.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 +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +6 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +7 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +3 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +28 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +24 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SpecialImportsConditionPatcher.cs +15 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +39 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/GroupUpdateAllVersionsHandlerTests.cs +162 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandlerTests.cs +311 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandlerTests.cs +273 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandlerTests.cs +307 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/SpecialFilePatcherTests.cs +25 -0
- metadata +4 -4
@@ -1,3 +1,5 @@
|
|
1
|
+
using System.Collections.Immutable;
|
2
|
+
|
1
3
|
using NuGet.Versioning;
|
2
4
|
|
3
5
|
using NuGetUpdater.Core.Analyze;
|
@@ -131,6 +133,311 @@ public class RefreshVersionUpdatePullRequestHandlerTests : UpdateHandlersTestsBa
|
|
131
133
|
);
|
132
134
|
}
|
133
135
|
|
136
|
+
[Fact]
|
137
|
+
public async Task GeneratesUpdatePullRequest_FirstUpdateDidNothingSecondUpdateSucceeded()
|
138
|
+
{
|
139
|
+
await TestAsync(
|
140
|
+
job: new Job()
|
141
|
+
{
|
142
|
+
Dependencies = ["Some.Dependency"],
|
143
|
+
ExistingPullRequests = [new() { Dependencies = [new() { DependencyName = "Some.Dependency", DependencyVersion = NuGetVersion.Parse("2.0.0") }] }],
|
144
|
+
Source = CreateJobSource("/src"),
|
145
|
+
UpdatingAPullRequest = true,
|
146
|
+
},
|
147
|
+
files: [
|
148
|
+
("src/project1.csproj", "initial contents"),
|
149
|
+
("src/project2.csproj", "initial contents"),
|
150
|
+
],
|
151
|
+
discoveryWorker: TestDiscoveryWorker.FromResults(
|
152
|
+
("/src", new WorkspaceDiscoveryResult()
|
153
|
+
{
|
154
|
+
Path = "/src",
|
155
|
+
Projects = [
|
156
|
+
new()
|
157
|
+
{
|
158
|
+
FilePath = "project1.csproj",
|
159
|
+
Dependencies = [
|
160
|
+
new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
161
|
+
new("Unrelated.Dependency", "3.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
162
|
+
],
|
163
|
+
ImportedFiles = [],
|
164
|
+
AdditionalFiles = [],
|
165
|
+
},
|
166
|
+
new()
|
167
|
+
{
|
168
|
+
FilePath = "project2.csproj",
|
169
|
+
Dependencies = [
|
170
|
+
new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
171
|
+
new("Unrelated.Dependency", "3.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
172
|
+
],
|
173
|
+
ImportedFiles = [],
|
174
|
+
AdditionalFiles = [],
|
175
|
+
},
|
176
|
+
],
|
177
|
+
})
|
178
|
+
),
|
179
|
+
analyzeWorker: new TestAnalyzeWorker(input =>
|
180
|
+
{
|
181
|
+
var repoRoot = input.Item1;
|
182
|
+
var discovery = input.Item2;
|
183
|
+
var dependencyInfo = input.Item3;
|
184
|
+
if (dependencyInfo.Name != "Some.Dependency")
|
185
|
+
{
|
186
|
+
throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}");
|
187
|
+
}
|
188
|
+
|
189
|
+
return Task.FromResult(new AnalysisResult()
|
190
|
+
{
|
191
|
+
CanUpdate = true,
|
192
|
+
UpdatedVersion = "2.0.0",
|
193
|
+
UpdatedDependencies = [],
|
194
|
+
});
|
195
|
+
}),
|
196
|
+
updaterWorker: new TestUpdaterWorker(async input =>
|
197
|
+
{
|
198
|
+
var repoRoot = input.Item1;
|
199
|
+
var workspacePath = input.Item2;
|
200
|
+
var dependencyName = input.Item3;
|
201
|
+
var previousVersion = input.Item4;
|
202
|
+
var newVersion = input.Item5;
|
203
|
+
var isTransitive = input.Item6;
|
204
|
+
|
205
|
+
ImmutableArray<UpdateOperationBase> updateOperations = [];
|
206
|
+
if (workspacePath.EndsWith("project2.csproj"))
|
207
|
+
{
|
208
|
+
// only report an update performed on the second project
|
209
|
+
updateOperations = [new DirectUpdate() { DependencyName = "Some.Dependency", NewVersion = NuGetVersion.Parse("2.0.0"), UpdatedFiles = ["/src/project2.csproj"] }];
|
210
|
+
await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
|
211
|
+
}
|
212
|
+
|
213
|
+
return new UpdateOperationResult()
|
214
|
+
{
|
215
|
+
UpdateOperations = updateOperations,
|
216
|
+
};
|
217
|
+
}),
|
218
|
+
expectedUpdateHandler: RefreshVersionUpdatePullRequestHandler.Instance,
|
219
|
+
expectedApiMessages: [
|
220
|
+
new UpdatedDependencyList()
|
221
|
+
{
|
222
|
+
Dependencies = [
|
223
|
+
new()
|
224
|
+
{
|
225
|
+
Name = "Some.Dependency",
|
226
|
+
Version = "1.0.0",
|
227
|
+
Requirements = [
|
228
|
+
new() { Requirement = "1.0.0", File = "/src/project1.csproj", Groups = ["dependencies"] },
|
229
|
+
],
|
230
|
+
},
|
231
|
+
new()
|
232
|
+
{
|
233
|
+
Name = "Unrelated.Dependency",
|
234
|
+
Version = "3.0.0",
|
235
|
+
Requirements = [
|
236
|
+
new() { Requirement = "3.0.0", File = "/src/project1.csproj", Groups = ["dependencies"] },
|
237
|
+
],
|
238
|
+
},
|
239
|
+
new()
|
240
|
+
{
|
241
|
+
Name = "Some.Dependency",
|
242
|
+
Version = "1.0.0",
|
243
|
+
Requirements = [
|
244
|
+
new() { Requirement = "1.0.0", File = "/src/project2.csproj", Groups = ["dependencies"] },
|
245
|
+
],
|
246
|
+
},
|
247
|
+
new()
|
248
|
+
{
|
249
|
+
Name = "Unrelated.Dependency",
|
250
|
+
Version = "3.0.0",
|
251
|
+
Requirements = [
|
252
|
+
new() { Requirement = "3.0.0", File = "/src/project2.csproj", Groups = ["dependencies"] },
|
253
|
+
],
|
254
|
+
},
|
255
|
+
],
|
256
|
+
DependencyFiles = ["/src/project1.csproj", "/src/project2.csproj"],
|
257
|
+
},
|
258
|
+
new IncrementMetric()
|
259
|
+
{
|
260
|
+
Metric = "updater.started",
|
261
|
+
Tags = new()
|
262
|
+
{
|
263
|
+
["operation"] = "update_version_pr",
|
264
|
+
}
|
265
|
+
},
|
266
|
+
new UpdatePullRequest()
|
267
|
+
{
|
268
|
+
DependencyNames = ["Some.Dependency"],
|
269
|
+
DependencyGroup = null,
|
270
|
+
UpdatedDependencyFiles = [
|
271
|
+
new()
|
272
|
+
{
|
273
|
+
Directory = "/src",
|
274
|
+
Name = "project2.csproj",
|
275
|
+
Content = "updated contents",
|
276
|
+
}
|
277
|
+
],
|
278
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
279
|
+
CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
|
280
|
+
PrTitle = RunWorkerTests.TestPullRequestTitle,
|
281
|
+
PrBody = RunWorkerTests.TestPullRequestBody,
|
282
|
+
},
|
283
|
+
new MarkAsProcessed("TEST-COMMIT-SHA"),
|
284
|
+
]
|
285
|
+
);
|
286
|
+
}
|
287
|
+
|
288
|
+
[Fact]
|
289
|
+
public async Task GeneratesUpdatePullRequest_FirstDependencyNotAbleToUpdate()
|
290
|
+
{
|
291
|
+
var responseNumber = 0; // used to track which request was sent
|
292
|
+
await TestAsync(
|
293
|
+
job: new Job()
|
294
|
+
{
|
295
|
+
Dependencies = ["Some.Dependency"],
|
296
|
+
ExistingPullRequests = [new() { Dependencies = [new() { DependencyName = "Some.Dependency", DependencyVersion = NuGetVersion.Parse("2.0.0") }] }],
|
297
|
+
Source = CreateJobSource("/src"),
|
298
|
+
UpdatingAPullRequest = true,
|
299
|
+
},
|
300
|
+
files: [
|
301
|
+
("src/project1.csproj", "initial contents"),
|
302
|
+
("src/project2.csproj", "initial contents"),
|
303
|
+
],
|
304
|
+
discoveryWorker: TestDiscoveryWorker.FromResults(
|
305
|
+
("/src", new WorkspaceDiscoveryResult()
|
306
|
+
{
|
307
|
+
Path = "/src",
|
308
|
+
Projects = [
|
309
|
+
new()
|
310
|
+
{
|
311
|
+
FilePath = "project1.csproj",
|
312
|
+
Dependencies = [
|
313
|
+
new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
314
|
+
new("Unrelated.Dependency", "3.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
315
|
+
],
|
316
|
+
ImportedFiles = [],
|
317
|
+
AdditionalFiles = [],
|
318
|
+
},
|
319
|
+
new()
|
320
|
+
{
|
321
|
+
FilePath = "project2.csproj",
|
322
|
+
Dependencies = [
|
323
|
+
new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
324
|
+
new("Unrelated.Dependency", "3.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
325
|
+
],
|
326
|
+
ImportedFiles = [],
|
327
|
+
AdditionalFiles = [],
|
328
|
+
},
|
329
|
+
],
|
330
|
+
})
|
331
|
+
),
|
332
|
+
analyzeWorker: new TestAnalyzeWorker(input =>
|
333
|
+
{
|
334
|
+
var repoRoot = input.Item1;
|
335
|
+
var discovery = input.Item2;
|
336
|
+
var dependencyInfo = input.Item3;
|
337
|
+
if (dependencyInfo.Name != "Some.Dependency")
|
338
|
+
{
|
339
|
+
throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}");
|
340
|
+
}
|
341
|
+
|
342
|
+
AnalysisResult result = responseNumber == 0
|
343
|
+
? new() { CanUpdate = false, UpdatedVersion = "1.0.0", UpdatedDependencies = [] }
|
344
|
+
: new() { CanUpdate = true, UpdatedVersion = "2.0.0", UpdatedDependencies = [] };
|
345
|
+
responseNumber++;
|
346
|
+
|
347
|
+
return Task.FromResult(result);
|
348
|
+
}),
|
349
|
+
updaterWorker: new TestUpdaterWorker(async input =>
|
350
|
+
{
|
351
|
+
var repoRoot = input.Item1;
|
352
|
+
var workspacePath = input.Item2;
|
353
|
+
var dependencyName = input.Item3;
|
354
|
+
var previousVersion = input.Item4;
|
355
|
+
var newVersion = input.Item5;
|
356
|
+
var isTransitive = input.Item6;
|
357
|
+
|
358
|
+
ImmutableArray<UpdateOperationBase> updateOperations = [];
|
359
|
+
if (workspacePath.EndsWith("project2.csproj"))
|
360
|
+
{
|
361
|
+
// only report an update performed on the second project
|
362
|
+
updateOperations = [new DirectUpdate() { DependencyName = "Some.Dependency", NewVersion = NuGetVersion.Parse("2.0.0"), UpdatedFiles = ["/src/project2.csproj"] }];
|
363
|
+
await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
|
364
|
+
}
|
365
|
+
|
366
|
+
return new UpdateOperationResult()
|
367
|
+
{
|
368
|
+
UpdateOperations = updateOperations,
|
369
|
+
};
|
370
|
+
}),
|
371
|
+
expectedUpdateHandler: RefreshVersionUpdatePullRequestHandler.Instance,
|
372
|
+
expectedApiMessages: [
|
373
|
+
new UpdatedDependencyList()
|
374
|
+
{
|
375
|
+
Dependencies = [
|
376
|
+
new()
|
377
|
+
{
|
378
|
+
Name = "Some.Dependency",
|
379
|
+
Version = "1.0.0",
|
380
|
+
Requirements = [
|
381
|
+
new() { Requirement = "1.0.0", File = "/src/project1.csproj", Groups = ["dependencies"] },
|
382
|
+
],
|
383
|
+
},
|
384
|
+
new()
|
385
|
+
{
|
386
|
+
Name = "Unrelated.Dependency",
|
387
|
+
Version = "3.0.0",
|
388
|
+
Requirements = [
|
389
|
+
new() { Requirement = "3.0.0", File = "/src/project1.csproj", Groups = ["dependencies"] },
|
390
|
+
],
|
391
|
+
},
|
392
|
+
new()
|
393
|
+
{
|
394
|
+
Name = "Some.Dependency",
|
395
|
+
Version = "1.0.0",
|
396
|
+
Requirements = [
|
397
|
+
new() { Requirement = "1.0.0", File = "/src/project2.csproj", Groups = ["dependencies"] },
|
398
|
+
],
|
399
|
+
},
|
400
|
+
new()
|
401
|
+
{
|
402
|
+
Name = "Unrelated.Dependency",
|
403
|
+
Version = "3.0.0",
|
404
|
+
Requirements = [
|
405
|
+
new() { Requirement = "3.0.0", File = "/src/project2.csproj", Groups = ["dependencies"] },
|
406
|
+
],
|
407
|
+
},
|
408
|
+
],
|
409
|
+
DependencyFiles = ["/src/project1.csproj", "/src/project2.csproj"],
|
410
|
+
},
|
411
|
+
new IncrementMetric()
|
412
|
+
{
|
413
|
+
Metric = "updater.started",
|
414
|
+
Tags = new()
|
415
|
+
{
|
416
|
+
["operation"] = "update_version_pr",
|
417
|
+
}
|
418
|
+
},
|
419
|
+
new UpdatePullRequest()
|
420
|
+
{
|
421
|
+
DependencyNames = ["Some.Dependency"],
|
422
|
+
DependencyGroup = null,
|
423
|
+
UpdatedDependencyFiles = [
|
424
|
+
new()
|
425
|
+
{
|
426
|
+
Directory = "/src",
|
427
|
+
Name = "project2.csproj",
|
428
|
+
Content = "updated contents",
|
429
|
+
}
|
430
|
+
],
|
431
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
432
|
+
CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
|
433
|
+
PrTitle = RunWorkerTests.TestPullRequestTitle,
|
434
|
+
PrBody = RunWorkerTests.TestPullRequestBody,
|
435
|
+
},
|
436
|
+
new MarkAsProcessed("TEST-COMMIT-SHA"),
|
437
|
+
]
|
438
|
+
);
|
439
|
+
}
|
440
|
+
|
134
441
|
[Fact]
|
135
442
|
public async Task GeneratesClosePullRequest_DependenciesRemoved()
|
136
443
|
{
|
@@ -1,4 +1,7 @@
|
|
1
|
+
using System.Text;
|
2
|
+
|
1
3
|
using NuGetUpdater.Core.Updater;
|
4
|
+
using NuGetUpdater.Core.Utilities;
|
2
5
|
|
3
6
|
using Xunit;
|
4
7
|
|
@@ -6,6 +9,28 @@ namespace NuGetUpdater.Core.Test.Update;
|
|
6
9
|
|
7
10
|
public class SpecialFilePatcherTests
|
8
11
|
{
|
12
|
+
[Fact]
|
13
|
+
public async Task ByteOrderMarkIsMaintained()
|
14
|
+
{
|
15
|
+
// arrange
|
16
|
+
using var tempDir = new TemporaryDirectory();
|
17
|
+
var projectFilePath = Path.Join(tempDir.DirectoryPath, "project.csproj");
|
18
|
+
var rawContent = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes("<Project>content with BOM</Project>")).ToArray();
|
19
|
+
Assert.True(rawContent.HasBOM(), "Expected byte order mark after initial write");
|
20
|
+
await File.WriteAllBytesAsync(projectFilePath, rawContent, TestContext.Current.CancellationToken);
|
21
|
+
|
22
|
+
// act
|
23
|
+
using (var special = new SpecialImportsConditionPatcher(projectFilePath))
|
24
|
+
{
|
25
|
+
var rawContentDuringPatching = await File.ReadAllBytesAsync(projectFilePath, TestContext.Current.CancellationToken);
|
26
|
+
Assert.True(rawContentDuringPatching.HasBOM(), "Expected byte order mark during patching");
|
27
|
+
}
|
28
|
+
|
29
|
+
// assert
|
30
|
+
var rawContentAfterPatching = await File.ReadAllBytesAsync(projectFilePath, TestContext.Current.CancellationToken);
|
31
|
+
Assert.True(rawContentAfterPatching.HasBOM(), "Expected byte order mark after patching");
|
32
|
+
}
|
33
|
+
|
9
34
|
[Theory]
|
10
35
|
[MemberData(nameof(SpecialImportsConditionPatcherTestData))]
|
11
36
|
public async Task SpecialImportsConditionPatcher(string fileContent, string expectedPatchedContent)
|
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.
|
4
|
+
version: 0.317.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.
|
18
|
+
version: 0.317.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.
|
25
|
+
version: 0.317.0
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rubyzip
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -580,7 +580,7 @@ licenses:
|
|
580
580
|
- MIT
|
581
581
|
metadata:
|
582
582
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
583
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
583
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.317.0
|
584
584
|
rdoc_options: []
|
585
585
|
require_paths:
|
586
586
|
- lib
|