Nullify GitHubClientFactory

This commit is contained in:
Jordan Dominion
2023-11-23 20:07:46 -05:00
parent e8d45282a8
commit 808ccc6643
@@ -9,8 +9,6 @@ using Octokit;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.System;
#nullable disable
namespace Tgstation.Server.Host.Utils.GitHub
{
/// <inheritdoc />
@@ -78,7 +76,7 @@ namespace Tgstation.Server.Host.Utils.GitHub
/// </summary>
/// <param name="accessToken">Optional access token to use as credentials.</param>
/// <returns>The <see cref="GitHubClient"/> for the given <paramref name="accessToken"/>.</returns>
GitHubClient GetOrCreateClient(string accessToken)
GitHubClient GetOrCreateClient(string? accessToken)
{
GitHubClient client;
bool cacheHit;
@@ -99,10 +97,11 @@ namespace Tgstation.Server.Host.Utils.GitHub
var now = DateTimeOffset.UtcNow;
if (!cacheHit)
{
var product = assemblyInformationProvider.ProductInfoHeaderValue.Product!;
client = new GitHubClient(
new ProductHeaderValue(
assemblyInformationProvider.ProductInfoHeaderValue.Product.Name,
assemblyInformationProvider.ProductInfoHeaderValue.Product.Version));
product.Name,
product.Version));
if (accessToken != null)
client.Credentials = new Credentials(accessToken);