dependabot-nuget 0.300.0 → 0.301.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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +1 -0
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +2 -0
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/ClosePullRequest.cs +1 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CommitOptions.cs +5 -1
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CreatePullRequest.cs +1 -1
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/GroupPullRequest.cs +1 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +36 -1
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +1 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/MessageBase.cs +5 -0
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PullRequest.cs +2 -5
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PullRequestDependency.cs +11 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdatePullRequest.cs +1 -1
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/CommitOptions_IncludeScopeConverter.cs +29 -0
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/HttpApiHandler.cs +5 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/IApiHandler.cs +1 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestConverter.cs +35 -0
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +44 -0
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +205 -49
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +76 -1
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +1 -1
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestMessageTests.cs +252 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +136 -0
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +145 -22
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +15 -10
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/TestApiHandler.cs +6 -0
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/{UpdateAllowedTests.cs → UpdatePermittedAndMessageTests.cs} +110 -6
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestHttpServer.cs +105 -0
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +75 -0
  30. metadata +13 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 332ca34b57d20f0c5690563f3aeb969fb638fb8a9a5e02e569dc1360ef5ad066
4
- data.tar.gz: 7dba4cc1963936c3b0b32dfa845e1285cb3bee679429da04c7cdad13590fc9dc
3
+ metadata.gz: 1ed2461d30ee17764d58b1b7b664156760ca001e107ffafc1125540ed6acbbfe
4
+ data.tar.gz: 66a59a3219fd47155367e43c646acbd91ed72e3049c95a3d7655f55ffdaf9c84
5
5
  SHA512:
6
- metadata.gz: 7b7a1770111410a3a3c9c7281e8e275f485e977e8c57290f7ea1d5e86219588d640bb82bf5c5f6d0a65b8b8a275edb4aadd051c0cc953df3cb62edc8fdf25a8d
7
- data.tar.gz: 1b2ed4ce448d6a239c28d3b448fa73096b211a03dbd8083bbc6168c6655c3cb5d3d76d07262c3e0aeb9f7ccd8a58d7372f6dd21dc2ce6dc428160313bb8b653f
6
+ metadata.gz: 30128ca31d2c0d16805a426f31cee881c7a67a2f33d764ca1055094fe4365fc804d6c0da7558be82ba68e558c7781a866ea7eb7324d35fbc953b6cf1d6afb17b
7
+ data.tar.gz: 943cef0fa6b587af0a2a93d78b04ce90fd6ba329223cbc9c596ab1f6692dff8904cbde43781e09191631217cbe4a4f311be8a8ef9188b174da9b0f979ec81347
@@ -28,6 +28,7 @@ internal static class DiscoverCommand
28
28
 
29
29
  command.SetHandler(async (jobId, jobPath, repoRoot, workspace, outputPath) =>
30
30
  {
31
+ MSBuildHelper.RegisterMSBuild(repoRoot.FullName, repoRoot.FullName);
31
32
  var (experimentsManager, error) = await ExperimentsManager.FromJobFileAsync(jobId, jobPath.FullName);
32
33
  if (error is not null)
33
34
  {
@@ -109,6 +109,8 @@ internal static class SdkProjectDiscovery
109
109
  $"/p:TargetFramework={tfm}",
110
110
  $"/p:CustomAfterMicrosoftCommonCrossTargetingTargets={dependencyDiscoveryTargetsPath}",
111
111
  $"/p:CustomAfterMicrosoftCommonTargets={dependencyDiscoveryTargetsPath}",
112
+ "/p:TreatWarningsAsErrors=false", // if using CPM and a project also sets TreatWarningsAsErrors to true, this can cause discovery to fail; explicitly don't allow that
113
+ "/p:MSBuildTreatWarningsAsErrors=false",
112
114
  $"/bl:{binLogPath}"
113
115
  };
114
116
  var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, startingProjectDirectory, experimentsManager);
@@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
3
3
 
4
4
  namespace NuGetUpdater.Core.Run.ApiModel;
5
5
 
6
- public sealed record ClosePullRequest
6
+ public sealed record ClosePullRequest : MessageBase
7
7
  {
8
8
  [JsonPropertyName("dependency-names")]
9
9
  public required ImmutableArray<string> DependencyNames { get; init; }
@@ -1,8 +1,12 @@
1
+ using System.Text.Json.Serialization;
2
+
1
3
  namespace NuGetUpdater.Core.Run.ApiModel;
2
4
 
3
5
  public record CommitOptions
4
6
  {
5
7
  public string? Prefix { get; init; } = null;
6
8
  public string? PrefixDevelopment { get; init; } = null;
7
- public bool? IncludeScope { get; init; } = null;
9
+
10
+ [JsonConverter(typeof(CommitOptions_IncludeScopeConverter))]
11
+ public bool IncludeScope { get; init; } = false;
8
12
  }
@@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
2
2
 
3
3
  namespace NuGetUpdater.Core.Run.ApiModel;
4
4
 
5
- public sealed record CreatePullRequest
5
+ public sealed record CreatePullRequest : MessageBase
6
6
  {
7
7
  public required ReportedDependency[] Dependencies { get; init; }
8
8
  [JsonPropertyName("updated-dependency-files")]
@@ -5,5 +5,5 @@ namespace NuGetUpdater.Core.Run.ApiModel;
5
5
  public record GroupPullRequest
6
6
  {
7
7
  public required string DependencyGroupName { get; init; }
8
- public required ImmutableArray<PullRequest> Dependencies { get; init; }
8
+ public required ImmutableArray<PullRequestDependency> Dependencies { get; init; }
9
9
  }
@@ -3,6 +3,7 @@ using System.Text.Json;
3
3
  using System.Text.Json.Serialization;
4
4
 
5
5
  using NuGet.Credentials;
6
+ using NuGet.Versioning;
6
7
 
7
8
  namespace NuGetUpdater.Core.Run.ApiModel;
8
9
 
@@ -16,7 +17,7 @@ public sealed record Job
16
17
  public ImmutableArray<DependencyGroup> DependencyGroups { get; init; } = [];
17
18
  public ImmutableArray<string>? Dependencies { get; init; } = null;
18
19
  public string? DependencyGroupToRefresh { get; init; } = null;
19
- public ImmutableArray<ImmutableArray<PullRequest>> ExistingPullRequests { get; init; } = [];
20
+ public ImmutableArray<PullRequest> ExistingPullRequests { get; init; } = [];
20
21
  public ImmutableArray<GroupPullRequest> ExistingGroupPullRequests { get; init; } = [];
21
22
  public Dictionary<string, object>? Experiments { get; init; } = null;
22
23
  public Condition[] IgnoreConditions { get; init; } = [];
@@ -54,6 +55,40 @@ public sealed record Job
54
55
  yield return "/";
55
56
  }
56
57
  }
58
+
59
+ public ImmutableArray<Tuple<string?, ImmutableArray<PullRequestDependency>>> GetAllExistingPullRequests()
60
+ {
61
+ var existingPullRequests = ExistingGroupPullRequests
62
+ .Select(pr => Tuple.Create((string?)pr.DependencyGroupName, pr.Dependencies))
63
+ .Concat(
64
+ ExistingPullRequests
65
+ .Select(pr => Tuple.Create((string?)null, pr.Dependencies)))
66
+ .ToImmutableArray();
67
+ return existingPullRequests;
68
+ }
69
+
70
+ public Tuple<string?, ImmutableArray<PullRequestDependency>>? GetExistingPullRequestForDependency(Dependency dependency)
71
+ {
72
+ if (dependency.Version is null)
73
+ {
74
+ return null;
75
+ }
76
+
77
+ var dependencyVersion = NuGetVersion.Parse(dependency.Version);
78
+ var existingPullRequests = GetAllExistingPullRequests();
79
+ var existingPullRequest = existingPullRequests.FirstOrDefault(pr =>
80
+ {
81
+ if (pr.Item2.Length == 1 &&
82
+ pr.Item2[0].DependencyName.Equals(dependency.Name, StringComparison.OrdinalIgnoreCase) &&
83
+ pr.Item2[0].DependencyVersion == dependencyVersion)
84
+ {
85
+ return true;
86
+ }
87
+
88
+ return false;
89
+ });
90
+ return existingPullRequest;
91
+ }
57
92
  }
58
93
 
59
94
  public class NullAsBoolConverter : JsonConverter<bool>
@@ -7,7 +7,7 @@ using NuGetUpdater.Core.Analyze;
7
7
 
8
8
  namespace NuGetUpdater.Core.Run.ApiModel;
9
9
 
10
- public abstract record JobErrorBase
10
+ public abstract record JobErrorBase : MessageBase
11
11
  {
12
12
  public JobErrorBase(string type)
13
13
  {
@@ -0,0 +1,5 @@
1
+ namespace NuGetUpdater.Core.Run.ApiModel;
2
+
3
+ public abstract record MessageBase
4
+ {
5
+ }
@@ -1,11 +1,8 @@
1
- using NuGet.Versioning;
1
+ using System.Collections.Immutable;
2
2
 
3
3
  namespace NuGetUpdater.Core.Run.ApiModel;
4
4
 
5
5
  public record PullRequest
6
6
  {
7
- public required string DependencyName { get; init; }
8
- public required NuGetVersion DependencyVersion { get; init; }
9
- public bool DependencyRemoved { get; init; } = false;
10
- public string? Directory { get; init; } = null;
7
+ public ImmutableArray<PullRequestDependency> Dependencies { get; init; } = [];
11
8
  }
@@ -0,0 +1,11 @@
1
+ using NuGet.Versioning;
2
+
3
+ namespace NuGetUpdater.Core.Run.ApiModel;
4
+
5
+ public record PullRequestDependency
6
+ {
7
+ public required string DependencyName { get; init; }
8
+ public required NuGetVersion DependencyVersion { get; init; }
9
+ public bool DependencyRemoved { get; init; } = false;
10
+ public string? Directory { get; init; } = null;
11
+ }
@@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
3
3
 
4
4
  namespace NuGetUpdater.Core.Run.ApiModel;
5
5
 
6
- public sealed record UpdatePullRequest
6
+ public sealed record UpdatePullRequest : MessageBase
7
7
  {
8
8
  [JsonPropertyName("base-commit-sha")]
9
9
  public required string BaseCommitSha { get; init; }
@@ -0,0 +1,29 @@
1
+ using System.Text.Json;
2
+ using System.Text.Json.Serialization;
3
+
4
+ namespace NuGetUpdater.Core.Run;
5
+
6
+ public class CommitOptions_IncludeScopeConverter : JsonConverter<bool>
7
+ {
8
+ public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
9
+ {
10
+ switch (reader.TokenType)
11
+ {
12
+ case JsonTokenType.True:
13
+ return true;
14
+ case JsonTokenType.False:
15
+ case JsonTokenType.Null:
16
+ return false;
17
+ case JsonTokenType.String:
18
+ var stringValue = reader.GetString();
19
+ return bool.Parse(stringValue!);
20
+ default:
21
+ throw new JsonException($"Unexpected token type {reader.TokenType}");
22
+ }
23
+ }
24
+
25
+ public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options)
26
+ {
27
+ writer.WriteBooleanValue(value);
28
+ }
29
+ }
@@ -45,6 +45,11 @@ public class HttpApiHandler : IApiHandler
45
45
  await PostAsJson("create_pull_request", createPullRequest);
46
46
  }
47
47
 
48
+ public async Task ClosePullRequest(ClosePullRequest closePullRequest)
49
+ {
50
+ await PostAsJson("close_pull_request", closePullRequest);
51
+ }
52
+
48
53
  public async Task UpdatePullRequest(UpdatePullRequest updatePullRequest)
49
54
  {
50
55
  await PostAsJson("update_pull_request", updatePullRequest);
@@ -8,6 +8,7 @@ public interface IApiHandler
8
8
  Task UpdateDependencyList(UpdatedDependencyList updatedDependencyList);
9
9
  Task IncrementMetric(IncrementMetric incrementMetric);
10
10
  Task CreatePullRequest(CreatePullRequest createPullRequest);
11
+ Task ClosePullRequest(ClosePullRequest closePullRequest);
11
12
  Task UpdatePullRequest(UpdatePullRequest updatePullRequest);
12
13
  Task MarkAsProcessed(MarkAsProcessed markAsProcessed);
13
14
  }
@@ -0,0 +1,35 @@
1
+ using System.Collections.Immutable;
2
+ using System.Text.Json;
3
+ using System.Text.Json.Serialization;
4
+
5
+ using NuGetUpdater.Core.Run.ApiModel;
6
+
7
+ namespace NuGetUpdater.Core.Analyze;
8
+
9
+ public class PullRequestConverter : JsonConverter<PullRequest>
10
+ {
11
+ public override PullRequest? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
12
+ {
13
+ if (reader.TokenType != JsonTokenType.StartArray)
14
+ {
15
+ throw new JsonException("expected array of pull request dependencies");
16
+ }
17
+
18
+ var dependencies = JsonSerializer.Deserialize<ImmutableArray<PullRequestDependency>>(ref reader, options);
19
+ return new PullRequest()
20
+ {
21
+ Dependencies = dependencies
22
+ };
23
+ }
24
+
25
+ public override void Write(Utf8JsonWriter writer, PullRequest value, JsonSerializerOptions options)
26
+ {
27
+ writer.WriteStartArray();
28
+ foreach (var dependency in value.Dependencies)
29
+ {
30
+ JsonSerializer.Serialize(writer, dependency, options);
31
+ }
32
+
33
+ writer.WriteEndArray();
34
+ }
35
+ }
@@ -0,0 +1,44 @@
1
+ using NuGet.Versioning;
2
+
3
+ using NuGetUpdater.Core.Run.ApiModel;
4
+
5
+ namespace NuGetUpdater.Core.Run;
6
+
7
+ public class PullRequestTextGenerator
8
+ {
9
+ public static string GetPullRequestTitle(Job job, ReportedDependency[] updatedDependencies, DependencyFile[] updatedFiles, string? dependencyGroupName = null)
10
+ {
11
+ // simple version looks like
12
+ // Update Some.Package to 1.2.3
13
+ // if multiple packages are updated to multiple versions, result looks like:
14
+ // Update Package.A to 1.0.0, 2.0.0; Package.B to 3.0.0, 4.0.0
15
+ var dependencySets = updatedDependencies
16
+ .GroupBy(d => d.Name, StringComparer.OrdinalIgnoreCase)
17
+ .OrderBy(g => g.Key, StringComparer.OrdinalIgnoreCase)
18
+ .Select(g => new
19
+ {
20
+ Name = g.Key,
21
+ Versions = g
22
+ .Where(d => d.Version is not null)
23
+ .Select(d => d.Version!)
24
+ .OrderBy(d => NuGetVersion.Parse(d))
25
+ .ToArray()
26
+ })
27
+ .ToArray();
28
+ var updatedPartTitles = dependencySets
29
+ .Select(d => $"{d.Name} to {string.Join(", ", d.Versions)}")
30
+ .ToArray();
31
+ var title = $"{job.CommitMessageOptions?.Prefix}Update {string.Join("; ", updatedPartTitles)}";
32
+ return title;
33
+ }
34
+
35
+ public static string GetPullRequestCommitMessage(Job job, ReportedDependency[] updatedDependencies, DependencyFile[] updatedFiles, string? dependencyGroupName = null)
36
+ {
37
+ return GetPullRequestTitle(job, updatedDependencies, updatedFiles, dependencyGroupName);
38
+ }
39
+
40
+ public static string GetPullRequestBody(Job job, ReportedDependency[] updatedDependencies, DependencyFile[] updatedFiles, string? dependencyGroupName = null)
41
+ {
42
+ return GetPullRequestTitle(job, updatedDependencies, updatedFiles, dependencyGroupName);
43
+ }
44
+ }