Skip to content

Commit

Permalink
Fix repository name detection on AppVeyor
Browse files Browse the repository at this point in the history
  • Loading branch information
aaubry committed Apr 8, 2021
1 parent 7ffbb84 commit 381ffec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions tools/build/BuildDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,13 @@ public static void Document(Options options)
");
}

private static string GitHubRepository => Environment.GetEnvironmentVariable("GITHUB_REPOSITORY") ?? "aaubry/YamlDotNet.Sandbox";

private static string GitHubRepository =>
Program.Host switch
{
Host.Appveyor => Environment.GetEnvironmentVariable("APPVEYOR_REPO_NAME"),
_ => Environment.GetEnvironmentVariable("GITHUB_REPOSITORY")
}
?? "aaubry/YamlDotNet.Sandbox";

private static readonly Lazy<HttpClient> GitHubClient = new Lazy<HttpClient>(() =>
{
Expand Down
6 changes: 3 additions & 3 deletions tools/build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Program
public static bool NoPrerelease { get; private set; }
public static string? ForcedVersion { get; private set; }
private static bool verbose;
private static Host host;
public static Host Host { get; private set; }
private static readonly Dictionary<Type, object> state = new Dictionary<Type, object>();

private static T GetState<T>() where T : notnull
Expand Down Expand Up @@ -136,7 +136,7 @@ static int Main(string[] args)

var (options, targets) = Options.Parse(filteredArguments);
verbose = options.Verbose;
host = options.Host.DetectIfUnknown().Item1;
Host = options.Host.DetectIfUnknown().Item1;

var operatingSystem =
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
Expand Down Expand Up @@ -234,7 +234,7 @@ public static void WriteWarning(string text)

public static void WriteImportant(string text)
{
switch (host)
switch (Host)
{
case Host.GitHubActions:
Console.WriteLine($"Writing a warning");
Expand Down

0 comments on commit 381ffec

Please sign in to comment.