dependabot-nuget 0.284.0 → 0.285.0

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: 0604d43cad05ef88f7471259b903ec56c1cf7d1bcf127b253bf6c0c2af8c66f0
4
- data.tar.gz: 9e4b41b0d72f5989abb57bc18f39116a1a2f5c00f935c7a0c2858e61da6bcb75
3
+ metadata.gz: d8dd6e625e132b28270ffbff6c1af11b0173e3a786a1f6518080c20adc028ac2
4
+ data.tar.gz: 7afe9afdd9b8ab5ae40372ac51fb292efce75ed4d4b5ba7fee96468e00e835bc
5
5
  SHA512:
6
- metadata.gz: 6f4b7300174349f5a5c5a5ebdc461a18ea2c08a06b0229043216e2f3b19bc5a5c2523f43735f0aeafd95f0bffea693791f307165dbb22a1d58ab81f19e89496e
7
- data.tar.gz: '0761288866aa1af50029cbd2f61d2423e06f51d090ed8ca4afb3b5afb9a4aa4b5389fa57a1fdad03b0de95895d3b43eb612cbb992660b44ca854bcc8303f1733'
6
+ metadata.gz: 0d9b4fdc7ba52be531cb199699324e7be1a68ae6a698619e961535f0cdb993833cc06e6e4f0df7a88f5b12e3a8bb06627a5ba2233e24bcafa4ade1badcf6a2bf
7
+ data.tar.gz: e9619a91fc865a8aa45a812a923f089a10e67f0be0c8588908206726e4e2b6d95ee1626cc0897d3dad5c5aca1a2e89f1c657e25a9137d4f186e05a7813b3e34c
@@ -63,7 +63,8 @@ public class RunWorker
63
63
  var result = await RunForDirectory(job, repoContentsPath, directory, baseCommitSha);
64
64
  foreach (var dependencyFile in result.Base64DependencyFiles)
65
65
  {
66
- allDependencyFiles[dependencyFile.Name] = dependencyFile;
66
+ var uniqueKey = Path.GetFullPath(Path.Join(dependencyFile.Directory, dependencyFile.Name)).NormalizePathToUnix().EnsurePrefix("/");
67
+ allDependencyFiles[uniqueKey] = dependencyFile;
67
68
  }
68
69
  }
69
70
 
@@ -110,7 +111,7 @@ public class RunWorker
110
111
  _logger.Log(JsonSerializer.Serialize(discoveryResult, DiscoveryWorker.SerializerOptions));
111
112
 
112
113
  // report dependencies
113
- var discoveredUpdatedDependencies = GetUpdatedDependencyListFromDiscovery(discoveryResult);
114
+ var discoveredUpdatedDependencies = GetUpdatedDependencyListFromDiscovery(discoveryResult, repoContentsPath.FullName);
114
115
  await _apiHandler.UpdateDependencyList(discoveredUpdatedDependencies);
115
116
 
116
117
  // TODO: pull out relevant dependencies, then check each for updates and track the changes
@@ -134,6 +135,16 @@ public class RunWorker
134
135
  var localPath = Path.Join(repoContentsPath.FullName, discoveryResult.Path, project.FilePath);
135
136
  var content = await File.ReadAllTextAsync(localPath);
136
137
  originalDependencyFileContents[path] = content;
138
+
139
+ // track packages.config if it exists
140
+ var projectDirectory = Path.GetDirectoryName(project.FilePath);
141
+ var packagesConfigPath = Path.Join(repoContentsPath.FullName, discoveryResult.Path, projectDirectory, "packages.config");
142
+ var normalizedPackagesConfigPath = Path.Join(discoveryResult.Path, projectDirectory, "packages.config").NormalizePathToUnix().EnsurePrefix("/");
143
+ if (File.Exists(packagesConfigPath))
144
+ {
145
+ var packagesConfigContent = await File.ReadAllTextAsync(packagesConfigPath);
146
+ originalDependencyFileContents[normalizedPackagesConfigPath] = packagesConfigContent;
147
+ }
137
148
  }
138
149
 
139
150
  // do update
@@ -168,9 +179,15 @@ public class RunWorker
168
179
  // TODO: log analysisResult
169
180
  if (analysisResult.CanUpdate)
170
181
  {
182
+ var dependencyLocation = Path.GetFullPath(Path.Join(discoveryResult.Path, project.FilePath).NormalizePathToUnix().EnsurePrefix("/"));
183
+ if (dependency.Type == DependencyType.PackagesConfig)
184
+ {
185
+ dependencyLocation = Path.Combine(Path.GetDirectoryName(dependencyLocation)!, "packages.config");
186
+ }
187
+
171
188
  // TODO: this is inefficient, but not likely causing a bottleneck
172
189
  var previousDependency = discoveredUpdatedDependencies.Dependencies
173
- .Single(d => d.Name == dependency.Name && d.Requirements.Single().File == Path.Join(discoveryResult.Path, project.FilePath).NormalizePathToUnix().EnsurePrefix("/"));
190
+ .Single(d => d.Name == dependency.Name && d.Requirements.Single().File == dependencyLocation);
174
191
  var updatedDependency = new ReportedDependency()
175
192
  {
176
193
  Name = dependency.Name,
@@ -179,7 +196,7 @@ public class RunWorker
179
196
  [
180
197
  new ReportedRequirement()
181
198
  {
182
- File = Path.Join(discoveryResult.Path, project.FilePath).NormalizePathToUnix().EnsurePrefix("/"),
199
+ File = dependencyLocation,
183
200
  Requirement = analysisResult.UpdatedVersion,
184
201
  Groups = previousDependency.Requirements.Single().Groups,
185
202
  Source = new RequirementSource()
@@ -198,6 +215,11 @@ public class RunWorker
198
215
  // TODO: need to report if anything was actually updated
199
216
  if (updateResult.ErrorType is null || updateResult.ErrorType == ErrorType.None)
200
217
  {
218
+ if (dependencyLocation != dependencyFilePath)
219
+ {
220
+ updatedDependency.Requirements.All(r => r.File == dependencyFilePath);
221
+ }
222
+
201
223
  actualUpdatedDependencies.Add(updatedDependency);
202
224
  }
203
225
  }
@@ -208,19 +230,40 @@ public class RunWorker
208
230
  var updatedDependencyFiles = new List<DependencyFile>();
209
231
  foreach (var project in discoveryResult.Projects)
210
232
  {
211
- var path = Path.Join(discoveryResult.Path, project.FilePath).NormalizePathToUnix().EnsurePrefix("/");
212
- var localPath = Path.Join(repoContentsPath.FullName, discoveryResult.Path, project.FilePath);
213
- var updatedContent = await File.ReadAllTextAsync(localPath);
214
- var originalContent = originalDependencyFileContents[path];
215
- if (updatedContent != originalContent)
233
+ var projectPath = Path.Join(discoveryResult.Path, project.FilePath).NormalizePathToUnix().EnsurePrefix("/");
234
+ var localProjectPath = Path.Join(repoContentsPath.FullName, discoveryResult.Path, project.FilePath);
235
+ var updatedProjectContent = await File.ReadAllTextAsync(localProjectPath);
236
+ var originalProjectContent = originalDependencyFileContents[projectPath];
237
+
238
+ if (updatedProjectContent != originalProjectContent)
216
239
  {
217
240
  updatedDependencyFiles.Add(new DependencyFile()
218
241
  {
219
242
  Name = project.FilePath,
220
- Content = updatedContent,
221
- Directory = discoveryResult.Path,
243
+ Content = updatedProjectContent,
244
+ Directory = Path.GetDirectoryName(projectPath)!.NormalizeUnixPathParts(),
222
245
  });
223
246
  }
247
+
248
+ var projectDirectory = Path.GetDirectoryName(project.FilePath);
249
+ var packagesConfigPath = Path.Join(repoContentsPath.FullName, discoveryResult.Path, projectDirectory, "packages.config");
250
+ var normalizedPackagesConfigPath = Path.Join(discoveryResult.Path, projectDirectory, "packages.config").NormalizePathToUnix().EnsurePrefix("/");
251
+
252
+ if (File.Exists(packagesConfigPath))
253
+ {
254
+ var updatedPackagesConfigContent = await File.ReadAllTextAsync(packagesConfigPath);
255
+ var originalPackagesConfigContent = originalDependencyFileContents[normalizedPackagesConfigPath];
256
+
257
+ if (updatedPackagesConfigContent != originalPackagesConfigContent)
258
+ {
259
+ updatedDependencyFiles.Add(new DependencyFile()
260
+ {
261
+ Name = Path.Join(projectDirectory!, "packages.config"),
262
+ Content = updatedPackagesConfigContent,
263
+ Directory = Path.GetDirectoryName(normalizedPackagesConfigPath)!.NormalizeUnixPathParts(),
264
+ });
265
+ }
266
+ }
224
267
  }
225
268
 
226
269
  if (updatedDependencyFiles.Count > 0)
@@ -253,14 +296,14 @@ public class RunWorker
253
296
  {
254
297
  Name = Path.GetFileName(kvp.Key),
255
298
  Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(kvp.Value)),
256
- Directory = Path.GetDirectoryName(kvp.Key)!.NormalizePathToUnix(),
299
+ Directory = Path.GetFullPath(Path.GetDirectoryName(kvp.Key)!).NormalizePathToUnix(),
257
300
  }).ToArray(),
258
301
  BaseCommitSha = baseCommitSha,
259
302
  };
260
303
  return result;
261
304
  }
262
305
 
263
- internal static UpdatedDependencyList GetUpdatedDependencyListFromDiscovery(WorkspaceDiscoveryResult discoveryResult)
306
+ internal static UpdatedDependencyList GetUpdatedDependencyListFromDiscovery(WorkspaceDiscoveryResult discoveryResult, string pathToContents)
264
307
  {
265
308
  string GetFullRepoPath(string path)
266
309
  {
@@ -282,6 +325,17 @@ public class RunWorker
282
325
  auxiliaryFiles.Add(GetFullRepoPath(discoveryResult.DirectoryPackagesProps.FilePath));
283
326
  }
284
327
 
328
+ foreach (var project in discoveryResult.Projects)
329
+ {
330
+ var projectDirectory = Path.GetDirectoryName(project.FilePath);
331
+ var pathToPackagesConfig = Path.Join(pathToContents, discoveryResult.Path, projectDirectory, "packages.config").NormalizePathToUnix().EnsurePrefix("/");
332
+
333
+ if (File.Exists(pathToPackagesConfig))
334
+ {
335
+ auxiliaryFiles.Add(GetFullRepoPath(Path.Join(projectDirectory, "packages.config")));
336
+ }
337
+ }
338
+
285
339
  var updatedDependencyList = new UpdatedDependencyList()
286
340
  {
287
341
  Dependencies = discoveryResult.Projects.SelectMany(p =>
@@ -292,7 +346,7 @@ public class RunWorker
292
346
  Name = d.Name,
293
347
  Requirements = d.IsTransitive ? [] : [new ReportedRequirement()
294
348
  {
295
- File = GetFullRepoPath(p.FilePath),
349
+ File = d.Type == DependencyType.PackagesConfig ? Path.Combine(Path.GetDirectoryName(GetFullRepoPath(p.FilePath))!, "packages.config"): GetFullRepoPath(p.FilePath),
296
350
  Requirement = d.Version!,
297
351
  Groups = ["dependencies"],
298
352
  }],
@@ -142,7 +142,7 @@ public class RunWorkerTests
142
142
  new DependencyFile()
143
143
  {
144
144
  Name = "project.csproj",
145
- Directory = "some-dir",
145
+ Directory = "/some-dir",
146
146
  Content = """
147
147
  <Project Sdk="Microsoft.NET.Sdk">
148
148
  <PropertyGroup>
@@ -250,14 +250,648 @@ public class RunWorkerTests
250
250
  );
251
251
  }
252
252
 
253
- private static async Task RunAsync(Job job, TestFile[] files, RunResult expectedResult, object[] expectedApiMessages, MockNuGetPackage[]? packages = null)
253
+ [Fact]
254
+ public async Task UpdateHandlesPackagesConfigFiles()
255
+ {
256
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
257
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
258
+ await RunAsync(
259
+ packages:
260
+ [
261
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", additionalMetadata: [repoMetadata]),
262
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.1", "net8.0", additionalMetadata: [repoMetadata]),
263
+ MockNuGetPackage.CreateSimplePackage("Some.Package2", "2.0.0", "net8.0", additionalMetadata: [repoMetadata2]),
264
+ MockNuGetPackage.CreateSimplePackage("Some.Package2", "2.0.1", "net8.0", additionalMetadata: [repoMetadata2]),
265
+ ],
266
+ job: new Job()
267
+ {
268
+ PackageManager = "nuget",
269
+ Source = new()
270
+ {
271
+ Provider = "github",
272
+ Repo = "test/repo",
273
+ Directory = "some-dir",
274
+ },
275
+ AllowedUpdates =
276
+ [
277
+ new() { UpdateType = "all" }
278
+ ]
279
+ },
280
+ files:
281
+ [
282
+ ("some-dir/project.csproj", """
283
+ <Project Sdk="Microsoft.NET.Sdk">
284
+ <PropertyGroup>
285
+ <TargetFramework>net8.0</TargetFramework>
286
+ </PropertyGroup>
287
+ <ItemGroup>
288
+ <PackageReference Include="Some.Package" Version="1.0.0" />
289
+ </ItemGroup>
290
+ </Project>
291
+ """),
292
+ ("some-dir/packages.config", """
293
+ <?xml version="1.0" encoding="utf-8"?>
294
+ <packages>
295
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
296
+ </packages>
297
+ """),
298
+ ],
299
+ expectedResult: new RunResult()
300
+ {
301
+ Base64DependencyFiles =
302
+ [
303
+ new DependencyFile()
304
+ {
305
+ Directory = "/some-dir",
306
+ Name = "project.csproj",
307
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
308
+ <Project Sdk="Microsoft.NET.Sdk">
309
+ <PropertyGroup>
310
+ <TargetFramework>net8.0</TargetFramework>
311
+ </PropertyGroup>
312
+ <ItemGroup>
313
+ <PackageReference Include="Some.Package" Version="1.0.0" />
314
+ </ItemGroup>
315
+ </Project>
316
+ """))
317
+ },
318
+ new DependencyFile()
319
+ {
320
+ Directory = "/some-dir",
321
+ Name = "packages.config",
322
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
323
+ <?xml version="1.0" encoding="utf-8"?>
324
+ <packages>
325
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
326
+ </packages>
327
+ """))
328
+ }
329
+ ],
330
+ BaseCommitSha = "TEST-COMMIT-SHA",
331
+ },
332
+ expectedApiMessages:
333
+ [
334
+ new UpdatedDependencyList()
335
+ {
336
+ Dependencies =
337
+ [
338
+ new ReportedDependency()
339
+ {
340
+ Name = "Some.Package",
341
+ Version = "1.0.0",
342
+ Requirements =
343
+ [
344
+ new ReportedRequirement()
345
+ {
346
+ Requirement = "1.0.0",
347
+ File = "/some-dir/project.csproj",
348
+ Groups = ["dependencies"],
349
+ }
350
+ ]
351
+ },
352
+ new ReportedDependency()
353
+ {
354
+ Name = "Some.Package2",
355
+ Version = "2.0.0",
356
+ Requirements =
357
+ [
358
+ new ReportedRequirement()
359
+ {
360
+ Requirement = "2.0.0",
361
+ File = "/some-dir/packages.config",
362
+ Groups = ["dependencies"],
363
+ }
364
+ ]
365
+ }
366
+ ],
367
+ DependencyFiles = ["/some-dir/project.csproj", "/some-dir/packages.config"],
368
+ },
369
+ new IncrementMetric()
370
+ {
371
+ Metric = "updater.started",
372
+ Tags = new()
373
+ {
374
+ ["operation"] = "group_update_all_versions"
375
+ }
376
+ },
377
+ new CreatePullRequest()
378
+ {
379
+ Dependencies =
380
+ [
381
+ new ReportedDependency()
382
+ {
383
+ Name = "Some.Package",
384
+ Version = "1.0.1",
385
+ Requirements =
386
+ [
387
+ new ReportedRequirement()
388
+ {
389
+ Requirement = "1.0.1",
390
+ File = "/some-dir/project.csproj",
391
+ Groups = ["dependencies"],
392
+ Source = new()
393
+ {
394
+ SourceUrl = "https://nuget.example.com/some-package",
395
+ Type = "nuget_repo",
396
+ }
397
+ }
398
+ ],
399
+ PreviousVersion = "1.0.0",
400
+ PreviousRequirements =
401
+ [
402
+ new ReportedRequirement()
403
+ {
404
+ Requirement = "1.0.0",
405
+ File = "/some-dir/project.csproj",
406
+ Groups = ["dependencies"],
407
+ }
408
+ ],
409
+ },
410
+ new ReportedDependency()
411
+ {
412
+ Name = "Some.Package2",
413
+ Version = "2.0.1",
414
+ Requirements =
415
+ [
416
+ new ReportedRequirement()
417
+ {
418
+ Requirement = "2.0.1",
419
+ File = "/some-dir/packages.config",
420
+ Groups = ["dependencies"],
421
+ Source = new()
422
+ {
423
+ SourceUrl = "https://nuget.example.com/some-package2",
424
+ Type = "nuget_repo",
425
+ }
426
+ }
427
+ ],
428
+ PreviousVersion = "2.0.0",
429
+ PreviousRequirements =
430
+ [
431
+ new ReportedRequirement()
432
+ {
433
+ Requirement = "2.0.0",
434
+ File = "/some-dir/packages.config",
435
+ Groups = ["dependencies"],
436
+ }
437
+ ],
438
+ },
439
+ ],
440
+ UpdatedDependencyFiles =
441
+ [
442
+ new DependencyFile()
443
+ {
444
+ Name = "project.csproj",
445
+ Directory = "/some-dir",
446
+ Content = """
447
+ <Project Sdk="Microsoft.NET.Sdk">
448
+ <PropertyGroup>
449
+ <TargetFramework>net8.0</TargetFramework>
450
+ </PropertyGroup>
451
+ <ItemGroup>
452
+ <PackageReference Include="Some.Package" Version="1.0.1" />
453
+ </ItemGroup>
454
+ <ItemGroup>
455
+ <Reference Include="Some.Package2">
456
+ <HintPath>..\packages\Some.Package2.2.0.1\lib\net8.0\Some.Package2.dll</HintPath>
457
+ <Private>True</Private>
458
+ </Reference>
459
+ </ItemGroup>
460
+ </Project>
461
+ """,
462
+ },
463
+ new DependencyFile()
464
+ {
465
+ Name = "packages.config",
466
+ Directory = "/some-dir",
467
+ Content = """
468
+ <?xml version="1.0" encoding="utf-8"?>
469
+ <packages>
470
+ <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
471
+ </packages>
472
+ """,
473
+ },
474
+ ],
475
+ BaseCommitSha = "TEST-COMMIT-SHA",
476
+ CommitMessage = "TODO: message",
477
+ PrTitle = "TODO: title",
478
+ PrBody = "TODO: body",
479
+ },
480
+ new MarkAsProcessed("TEST-COMMIT-SHA")
481
+ ]
482
+ );
483
+ }
484
+
485
+ [Fact]
486
+ public async Task UpdateHandlesPackagesConfigFromReferencedCsprojFiles()
487
+ {
488
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
489
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
490
+ await RunAsync(
491
+ packages:
492
+ [
493
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", additionalMetadata: [repoMetadata]),
494
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.1", "net8.0", additionalMetadata: [repoMetadata]),
495
+ MockNuGetPackage.CreateSimplePackage("Some.Package2", "2.0.0", "net8.0", additionalMetadata: [repoMetadata2]),
496
+ MockNuGetPackage.CreateSimplePackage("Some.Package2", "2.0.1", "net8.0", additionalMetadata: [repoMetadata2]),
497
+ ],
498
+ job: new Job()
499
+ {
500
+ PackageManager = "nuget",
501
+ Source = new()
502
+ {
503
+ Provider = "github",
504
+ Repo = "test/repo",
505
+ Directory = "some-dir/ProjectA",
506
+ },
507
+ AllowedUpdates =
508
+ [
509
+ new() { UpdateType = "all" }
510
+ ]
511
+ },
512
+ files:
513
+ [
514
+ ("some-dir/ProjectA/ProjectA.csproj", """
515
+ <Project Sdk="Microsoft.NET.Sdk">
516
+ <PropertyGroup>
517
+ <TargetFramework>net8.0</TargetFramework>
518
+ </PropertyGroup>
519
+ <ItemGroup>
520
+ <PackageReference Include="Some.Package" Version="1.0.0" />
521
+ </ItemGroup>
522
+ <ItemGroup>
523
+ <ProjectReference Include="../ProjectB/ProjectB.csproj" />
524
+ </ItemGroup>
525
+ </Project>
526
+ """),
527
+ ("some-dir/ProjectA/packages.config", """
528
+ <?xml version="1.0" encoding="utf-8"?>
529
+ <packages>
530
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
531
+ </packages>
532
+ """),
533
+ ("some-dir/ProjectB/ProjectB.csproj", """
534
+ <Project Sdk="Microsoft.NET.Sdk">
535
+ <PropertyGroup>
536
+ <TargetFramework>net8.0</TargetFramework>
537
+ </PropertyGroup>
538
+ <ItemGroup>
539
+ <PackageReference Include="Some.Package" Version="1.0.0" />
540
+ </ItemGroup>
541
+ </Project>
542
+ """),
543
+ ("some-dir/ProjectB/packages.config", """
544
+ <?xml version="1.0" encoding="utf-8"?>
545
+ <packages>
546
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
547
+ </packages>
548
+ """),
549
+ ],
550
+ expectedResult: new RunResult()
551
+ {
552
+ Base64DependencyFiles =
553
+ [
554
+ new DependencyFile()
555
+ {
556
+ Directory = "/some-dir/ProjectB",
557
+ Name = "ProjectB.csproj",
558
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
559
+ <Project Sdk="Microsoft.NET.Sdk">
560
+ <PropertyGroup>
561
+ <TargetFramework>net8.0</TargetFramework>
562
+ </PropertyGroup>
563
+ <ItemGroup>
564
+ <PackageReference Include="Some.Package" Version="1.0.0" />
565
+ </ItemGroup>
566
+ </Project>
567
+ """))
568
+ },
569
+ new DependencyFile()
570
+ {
571
+ Directory = "/some-dir/ProjectB",
572
+ Name = "packages.config",
573
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
574
+ <?xml version="1.0" encoding="utf-8"?>
575
+ <packages>
576
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
577
+ </packages>
578
+ """))
579
+ },
580
+ new DependencyFile()
581
+ {
582
+ Directory = "/some-dir/ProjectA",
583
+ Name = "ProjectA.csproj",
584
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
585
+ <Project Sdk="Microsoft.NET.Sdk">
586
+ <PropertyGroup>
587
+ <TargetFramework>net8.0</TargetFramework>
588
+ </PropertyGroup>
589
+ <ItemGroup>
590
+ <PackageReference Include="Some.Package" Version="1.0.0" />
591
+ </ItemGroup>
592
+ <ItemGroup>
593
+ <ProjectReference Include="../ProjectB/ProjectB.csproj" />
594
+ </ItemGroup>
595
+ </Project>
596
+ """))
597
+ },
598
+ new DependencyFile()
599
+ {
600
+ Directory = "/some-dir/ProjectA",
601
+ Name = "packages.config",
602
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
603
+ <?xml version="1.0" encoding="utf-8"?>
604
+ <packages>
605
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
606
+ </packages>
607
+ """))
608
+ },
609
+ ],
610
+ BaseCommitSha = "TEST-COMMIT-SHA",
611
+ },
612
+ expectedApiMessages:
613
+ [
614
+ new UpdatedDependencyList()
615
+ {
616
+ Dependencies =
617
+ [
618
+ new ReportedDependency()
619
+ {
620
+ Name = "Some.Package",
621
+ Version = "1.0.0",
622
+ Requirements =
623
+ [
624
+ new ReportedRequirement()
625
+ {
626
+ Requirement = "1.0.0",
627
+ File = "/some-dir/ProjectB/ProjectB.csproj",
628
+ Groups = ["dependencies"],
629
+ }
630
+ ]
631
+ },
632
+ new ReportedDependency()
633
+ {
634
+ Name = "Some.Package2",
635
+ Version = "2.0.0",
636
+ Requirements =
637
+ [
638
+ new ReportedRequirement()
639
+ {
640
+ Requirement = "2.0.0",
641
+ File = "/some-dir/ProjectB/packages.config",
642
+ Groups = ["dependencies"],
643
+ }
644
+ ]
645
+ },
646
+ new ReportedDependency()
647
+ {
648
+ Name = "Some.Package",
649
+ Version = "1.0.0",
650
+ Requirements =
651
+ [
652
+ new ReportedRequirement()
653
+ {
654
+ Requirement = "1.0.0",
655
+ File = "/some-dir/ProjectA/ProjectA.csproj",
656
+ Groups = ["dependencies"],
657
+ }
658
+ ]
659
+ },
660
+ new ReportedDependency()
661
+ {
662
+ Name = "Some.Package2",
663
+ Version = "2.0.0",
664
+ Requirements =
665
+ [
666
+ new ReportedRequirement()
667
+ {
668
+ Requirement = "2.0.0",
669
+ File = "/some-dir/ProjectA/packages.config",
670
+ Groups = ["dependencies"],
671
+ }
672
+ ]
673
+ },
674
+ ],
675
+ DependencyFiles = ["/some-dir/ProjectB/ProjectB.csproj", "/some-dir/ProjectA/ProjectA.csproj", "/some-dir/ProjectB/packages.config", "/some-dir/ProjectA/packages.config"],
676
+ },
677
+ new IncrementMetric()
678
+ {
679
+ Metric = "updater.started",
680
+ Tags = new()
681
+ {
682
+ ["operation"] = "group_update_all_versions"
683
+ }
684
+ },
685
+ new CreatePullRequest()
686
+ {
687
+ Dependencies =
688
+ [
689
+ new ReportedDependency()
690
+ {
691
+ Name = "Some.Package",
692
+ Version = "1.0.1",
693
+ Requirements =
694
+ [
695
+ new ReportedRequirement()
696
+ {
697
+ Requirement = "1.0.1",
698
+ File = "/some-dir/ProjectB/ProjectB.csproj",
699
+ Groups = ["dependencies"],
700
+ Source = new()
701
+ {
702
+ SourceUrl = "https://nuget.example.com/some-package",
703
+ Type = "nuget_repo",
704
+ }
705
+ }
706
+ ],
707
+ PreviousVersion = "1.0.0",
708
+ PreviousRequirements =
709
+ [
710
+ new ReportedRequirement()
711
+ {
712
+ Requirement = "1.0.0",
713
+ File = "/some-dir/ProjectB/ProjectB.csproj",
714
+ Groups = ["dependencies"],
715
+ }
716
+ ],
717
+ },
718
+ new ReportedDependency()
719
+ {
720
+ Name = "Some.Package2",
721
+ Version = "2.0.1",
722
+ Requirements =
723
+ [
724
+ new ReportedRequirement()
725
+ {
726
+ Requirement = "2.0.1",
727
+ File = "/some-dir/ProjectB/packages.config",
728
+ Groups = ["dependencies"],
729
+ Source = new()
730
+ {
731
+ SourceUrl = "https://nuget.example.com/some-package2",
732
+ Type = "nuget_repo",
733
+ }
734
+ }
735
+ ],
736
+ PreviousVersion = "2.0.0",
737
+ PreviousRequirements =
738
+ [
739
+ new ReportedRequirement()
740
+ {
741
+ Requirement = "2.0.0",
742
+ File = "/some-dir/ProjectB/packages.config",
743
+ Groups = ["dependencies"],
744
+ }
745
+ ],
746
+ },
747
+ new ReportedDependency()
748
+ {
749
+ Name = "Some.Package",
750
+ Version = "1.0.1",
751
+ Requirements =
752
+ [
753
+ new ReportedRequirement()
754
+ {
755
+ Requirement = "1.0.1",
756
+ File = "/some-dir/ProjectA/ProjectA.csproj",
757
+ Groups = ["dependencies"],
758
+ Source = new()
759
+ {
760
+ SourceUrl = "https://nuget.example.com/some-package",
761
+ Type = "nuget_repo",
762
+ }
763
+ }
764
+ ],
765
+ PreviousVersion = "1.0.0",
766
+ PreviousRequirements =
767
+ [
768
+ new ReportedRequirement()
769
+ {
770
+ Requirement = "1.0.0",
771
+ File = "/some-dir/ProjectA/ProjectA.csproj",
772
+ Groups = ["dependencies"],
773
+ }
774
+ ],
775
+ },
776
+ new ReportedDependency()
777
+ {
778
+ Name = "Some.Package2",
779
+ Version = "2.0.1",
780
+ Requirements =
781
+ [
782
+ new ReportedRequirement()
783
+ {
784
+ Requirement = "2.0.1",
785
+ File = "/some-dir/ProjectA/packages.config",
786
+ Groups = ["dependencies"],
787
+ Source = new()
788
+ {
789
+ SourceUrl = "https://nuget.example.com/some-package2",
790
+ Type = "nuget_repo",
791
+ }
792
+ }
793
+ ],
794
+ PreviousVersion = "2.0.0",
795
+ PreviousRequirements =
796
+ [
797
+ new ReportedRequirement()
798
+ {
799
+ Requirement = "2.0.0",
800
+ File = "/some-dir/ProjectA/packages.config",
801
+ Groups = ["dependencies"],
802
+ }
803
+ ],
804
+ },
805
+ ],
806
+ UpdatedDependencyFiles =
807
+ [
808
+ new DependencyFile()
809
+ {
810
+ Name = "../ProjectB/ProjectB.csproj",
811
+ Directory = "/some-dir/ProjectB",
812
+ Content = """
813
+ <Project Sdk="Microsoft.NET.Sdk">
814
+ <PropertyGroup>
815
+ <TargetFramework>net8.0</TargetFramework>
816
+ </PropertyGroup>
817
+ <ItemGroup>
818
+ <PackageReference Include="Some.Package" Version="1.0.1" />
819
+ </ItemGroup>
820
+ <ItemGroup>
821
+ <Reference Include="Some.Package2">
822
+ <HintPath>..\packages\Some.Package2.2.0.1\lib\net8.0\Some.Package2.dll</HintPath>
823
+ <Private>True</Private>
824
+ </Reference>
825
+ </ItemGroup>
826
+ </Project>
827
+ """,
828
+ },
829
+ new DependencyFile()
830
+ {
831
+ Name = "../ProjectB/packages.config",
832
+ Directory = "/some-dir/ProjectB",
833
+ Content = """
834
+ <?xml version="1.0" encoding="utf-8"?>
835
+ <packages>
836
+ <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
837
+ </packages>
838
+ """,
839
+ },
840
+ new DependencyFile()
841
+ {
842
+ Name = "ProjectA.csproj",
843
+ Directory = "/some-dir/ProjectA",
844
+ Content = """
845
+ <Project Sdk="Microsoft.NET.Sdk">
846
+ <PropertyGroup>
847
+ <TargetFramework>net8.0</TargetFramework>
848
+ </PropertyGroup>
849
+ <ItemGroup>
850
+ <PackageReference Include="Some.Package" Version="1.0.1" />
851
+ </ItemGroup>
852
+ <ItemGroup>
853
+ <ProjectReference Include="../ProjectB/ProjectB.csproj" />
854
+ </ItemGroup>
855
+ <ItemGroup>
856
+ <Reference Include="Some.Package2">
857
+ <HintPath>..\packages\Some.Package2.2.0.1\lib\net8.0\Some.Package2.dll</HintPath>
858
+ <Private>True</Private>
859
+ </Reference>
860
+ </ItemGroup>
861
+ </Project>
862
+ """,
863
+ },
864
+ new DependencyFile()
865
+ {
866
+ Name = "packages.config",
867
+ Directory = "/some-dir/ProjectA",
868
+ Content = """
869
+ <?xml version="1.0" encoding="utf-8"?>
870
+ <packages>
871
+ <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
872
+ </packages>
873
+ """,
874
+ },
875
+ ],
876
+ BaseCommitSha = "TEST-COMMIT-SHA",
877
+ CommitMessage = "TODO: message",
878
+ PrTitle = "TODO: title",
879
+ PrBody = "TODO: body",
880
+ },
881
+ new MarkAsProcessed("TEST-COMMIT-SHA")
882
+ ]
883
+ );
884
+ }
885
+
886
+ private static async Task RunAsync(Job job, TestFile[] files, RunResult? expectedResult, object[] expectedApiMessages, MockNuGetPackage[]? packages = null, string? repoContentsPath = null)
254
887
  {
255
888
  // arrange
256
889
  using var tempDirectory = new TemporaryDirectory();
257
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, tempDirectory.DirectoryPath);
890
+ repoContentsPath ??= tempDirectory.DirectoryPath;
891
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, repoContentsPath);
258
892
  foreach (var (path, content) in files)
259
893
  {
260
- var fullPath = Path.Combine(tempDirectory.DirectoryPath, path);
894
+ var fullPath = Path.Combine(repoContentsPath, path);
261
895
  var directory = Path.GetDirectoryName(fullPath)!;
262
896
  Directory.CreateDirectory(directory);
263
897
  await File.WriteAllTextAsync(fullPath, content);
@@ -266,8 +900,8 @@ public class RunWorkerTests
266
900
  // act
267
901
  var testApiHandler = new TestApiHandler();
268
902
  var worker = new RunWorker(testApiHandler, new TestLogger());
269
- var repoContentsPath = new DirectoryInfo(tempDirectory.DirectoryPath);
270
- var actualResult = await worker.RunAsync(job, repoContentsPath, "TEST-COMMIT-SHA");
903
+ var repoContentsPathDirectoryInfo = new DirectoryInfo(repoContentsPath);
904
+ var actualResult = await worker.RunAsync(job, repoContentsPathDirectoryInfo, "TEST-COMMIT-SHA");
271
905
  var actualApiMessages = testApiHandler.ReceivedMessages.ToArray();
272
906
 
273
907
  // assert
@@ -13,6 +13,18 @@ public class UpdatedDependencyListTests
13
13
  [Fact]
14
14
  public void GetUpdatedDependencyListFromDiscovery()
15
15
  {
16
+ using var temp = new TemporaryDirectory();
17
+ Directory.CreateDirectory(Path.Combine(temp.DirectoryPath, "src", "a"));
18
+ Directory.CreateDirectory(Path.Combine(temp.DirectoryPath, "src", "b"));
19
+ Directory.CreateDirectory(Path.Combine(temp.DirectoryPath, "src", "c"));
20
+
21
+ File.WriteAllText(Path.Combine(temp.DirectoryPath, "src", "a", "packages.config"), "");
22
+ File.WriteAllText(Path.Combine(temp.DirectoryPath, "src", "b", "packages.config"), "");
23
+ File.WriteAllText(Path.Combine(temp.DirectoryPath, "src", "c", "packages.config"), "");
24
+ File.WriteAllText(Path.Combine(temp.DirectoryPath, "src", "a", "project.csproj"), "");
25
+ File.WriteAllText(Path.Combine(temp.DirectoryPath, "src", "b", "project.csproj"), "");
26
+ File.WriteAllText(Path.Combine(temp.DirectoryPath, "src", "c", "project.csproj"), "");
27
+
16
28
  var discovery = new WorkspaceDiscoveryResult()
17
29
  {
18
30
  Path = "src",
@@ -20,10 +32,31 @@ public class UpdatedDependencyListTests
20
32
  Projects = [
21
33
  new()
22
34
  {
23
- FilePath = "project.csproj",
35
+ FilePath = "a/project.csproj",
24
36
  Dependencies = [
25
37
  new("Microsoft.Extensions.DependencyModel", "6.0.0", DependencyType.PackageReference, TargetFrameworks: ["net6.0"]),
38
+ ],
39
+ IsSuccess = true,
40
+ Properties = [],
41
+ TargetFrameworks = ["net8.0"],
42
+ ReferencedProjectPaths = [],
43
+ },
44
+ new()
45
+ {
46
+ FilePath = "b/project.csproj",
47
+ Dependencies = [
48
+ ],
49
+ IsSuccess = true,
50
+ Properties = [],
51
+ TargetFrameworks = ["net8.0"],
52
+ ReferencedProjectPaths = [],
53
+ },
54
+ new()
55
+ {
56
+ FilePath = "c/project.csproj",
57
+ Dependencies = [
26
58
  new("System.Text.Json", "6.0.0", DependencyType.Unknown, TargetFrameworks: ["net6.0"], IsTransitive: true),
59
+ new("Newtonsoft.Json", "13.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net6.0"]),
27
60
  ],
28
61
  IsSuccess = true,
29
62
  Properties = [],
@@ -32,7 +65,7 @@ public class UpdatedDependencyListTests
32
65
  }
33
66
  ]
34
67
  };
35
- var updatedDependencyList = RunWorker.GetUpdatedDependencyListFromDiscovery(discovery);
68
+ var updatedDependencyList = RunWorker.GetUpdatedDependencyListFromDiscovery(discovery, pathToContents: temp.DirectoryPath);
36
69
  var expectedDependencyList = new UpdatedDependencyList()
37
70
  {
38
71
  Dependencies =
@@ -46,9 +79,9 @@ public class UpdatedDependencyListTests
46
79
  new ReportedRequirement()
47
80
  {
48
81
  Requirement = "6.0.0",
49
- File = "/src/project.csproj",
82
+ File = "/src/a/project.csproj",
50
83
  Groups = ["dependencies"],
51
- }
84
+ },
52
85
  ]
53
86
  },
54
87
  new ReportedDependency()
@@ -56,9 +89,23 @@ public class UpdatedDependencyListTests
56
89
  Name = "System.Text.Json",
57
90
  Version = "6.0.0",
58
91
  Requirements = [],
59
- }
92
+ },
93
+ new ReportedDependency()
94
+ {
95
+ Name = "Newtonsoft.Json",
96
+ Version = "13.0.1",
97
+ Requirements =
98
+ [
99
+ new ReportedRequirement()
100
+ {
101
+ Requirement = "13.0.1",
102
+ File = "/src/c/packages.config",
103
+ Groups = ["dependencies"],
104
+ },
105
+ ]
106
+ },
60
107
  ],
61
- DependencyFiles = ["/src/project.csproj"],
108
+ DependencyFiles = ["/src/a/project.csproj", "/src/b/project.csproj", "/src/c/project.csproj", "/src/a/packages.config", "/src/b/packages.config", "/src/c/packages.config"],
62
109
  };
63
110
 
64
111
  // doing JSON comparison makes this easier; we don't have to define custom record equality and we get an easy diff
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.284.0
4
+ version: 0.285.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2024-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.284.0
19
+ version: 0.285.0
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.284.0
26
+ version: 0.285.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubyzip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -505,7 +505,7 @@ licenses:
505
505
  - MIT
506
506
  metadata:
507
507
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
508
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.284.0
508
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.285.0
509
509
  post_install_message:
510
510
  rdoc_options: []
511
511
  require_paths: