Skip to content

Commit

Permalink
Fix repo request
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed Dec 18, 2024
1 parent 7ff3ff1 commit 326c4f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Src/GBX.NET.Tool.CLI/ToolConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public async Task RunAsync(ExecuteLogic executeLogic, CancellationToken cancella
// Request update info and additional stuff
var updateChecker = toolSettings.ConsoleSettings.DisableUpdateCheck
? null
: ToolUpdateChecker.Check(http, cancellationToken);
: ToolUpdateChecker.Check(http, options.GitHubRepo, cancellationToken);

if (introWriterTask is not null)
{
Expand Down
5 changes: 5 additions & 0 deletions Src/GBX.NET.Tool.CLI/ToolConsoleOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ public sealed record ToolConsoleOptions
public YamlDotNet.Serialization.DeserializerBuilder? YmlDeserializer { get; init; }
public YamlDotNet.Serialization.SerializerBuilder? YmlSerializer { get; init; }
public YamlDotNet.Serialization.StaticContext? YmlContext { get; init; }

/// <summary>
/// GitHub repository identifier where the releases are located. Format: <c>user/repo</c>
/// </summary>
public string? GitHubRepo { get; set; }
}
9 changes: 7 additions & 2 deletions Src/GBX.NET.Tool.CLI/ToolUpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ public ToolUpdateChecker(Task<HttpResponseMessage> updateInfoResponseTask)
this.updateInfoResponseTask = updateInfoResponseTask;
}

public static ToolUpdateChecker Check(HttpClient client, CancellationToken cancellationToken)
public static ToolUpdateChecker? Check(HttpClient client, string? githubRepo, CancellationToken cancellationToken)
{
var responseTask = client.GetAsync("https://api.github.com/repos/GBX.NET/GBX.NET.Tool/releases/latest", cancellationToken);
if (githubRepo is null)
{
return null;
}

var responseTask = client.GetAsync($"https://api.github.com/repos/{githubRepo}/releases/latest", cancellationToken);
return new ToolUpdateChecker(responseTask);
}

Expand Down

0 comments on commit 326c4f4

Please sign in to comment.