Skip to content

Commit 31689d6

Browse files
authored
chore:Add message to NugetVersionDeprecator when there are no packages to deprecate. (#2999)
1 parent e8bec02 commit 31689d6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

build/NugetVersionDeprecator/Program.cs

+9-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ internal class Program
2121

2222
private const string NerdGraphQueryJson = "{ \"query\": \"{ docs { agentReleases(agentName: DOTNET) { version eolDate } } }\" }";
2323

24-
2524
static async Task<int> Main(string[] args)
2625
{
2726
try
@@ -38,19 +37,18 @@ static async Task<int> Main(string[] args)
3837

3938
var nerdGraphResponse = await QueryNerdGraphAsync(options.ApiKey, NewRelicUrl);
4039

41-
var agentReleases = ParseNerdGraphResponse(DateTime.UtcNow, nerdGraphResponse);
42-
if (agentReleases.Any())
40+
var deprecatedAgentReleases = GetDeprecatedAgentReleasesFromNerdGraphResponse(DateTime.UtcNow, nerdGraphResponse);
41+
if (deprecatedAgentReleases.Any())
4342
{
4443
List<PackageDeprecationInfo> packagesToDeprecate = new();
45-
4644
foreach (var package in configuration.Packages)
4745
{
48-
packagesToDeprecate.AddRange(await GetPackagesToDeprecateAsync(package, agentReleases));
46+
packagesToDeprecate.AddRange(await GetPackagesToDeprecateAsync(package, deprecatedAgentReleases));
4947
}
5048

5149
if (packagesToDeprecate.Any())
5250
{
53-
var message = ReportPackagesToDeprecate(packagesToDeprecate, agentReleases);
51+
var message = ReportPackagesToDeprecate(packagesToDeprecate, deprecatedAgentReleases);
5452
Console.WriteLine(message);
5553

5654
if (!options.TestMode)
@@ -62,7 +60,10 @@ static async Task<int> Main(string[] args)
6260
return -1;
6361
}
6462
}
65-
63+
}
64+
else
65+
{
66+
Console.WriteLine("No releases are ready to deprecate.");
6667
}
6768
}
6869
else
@@ -106,7 +107,7 @@ private static async Task<string> QueryNerdGraphAsync(string apiKey, string url)
106107
return response.Content;
107108
}
108109

109-
private static List<AgentRelease> ParseNerdGraphResponse(DateTime releaseDate, string nerdGraphResponse)
110+
private static List<AgentRelease> GetDeprecatedAgentReleasesFromNerdGraphResponse(DateTime releaseDate, string nerdGraphResponse)
110111
{
111112
// parse the NerdGraph response -- we want to deserialize data.docs.agentReleases into an array of AgentRelease
112113
var parsedResponse = JObject.Parse(nerdGraphResponse);

0 commit comments

Comments
 (0)