Improve logic around decide IsHostedServer. (#4086)

This commit is contained in:
Tingluo Huang
2025-10-22 00:00:44 -04:00
committed by GitHub
parent 1b8efb99f6
commit bca18f71d0

View File

@@ -1,10 +1,10 @@
using GitHub.Runner.Sdk;
using System;
using System;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using GitHub.Runner.Sdk;
namespace GitHub.Runner.Common
{
@@ -64,8 +64,20 @@ namespace GitHub.Runner.Common
{
get
{
// Old runners do not have this property. Hosted runners likely don't have this property either.
return _isHostedServer ?? true;
// If the value has been explicitly set, return it.
if (_isHostedServer.HasValue)
{
return _isHostedServer.Value;
}
// Otherwise, try to infer it from the GitHubUrl.
if (!string.IsNullOrEmpty(GitHubUrl))
{
return UrlUtil.IsHostedServer(new UriBuilder(GitHubUrl));
}
// Default to true since Hosted runners likely don't have this property set.
return true;
}
set