Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Skip the source GHES version check when the source host ends in `ghe.com`
14 changes: 14 additions & 0 deletions src/OctoshiftCLI.Tests/gei/Services/GhesVersionCheckerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,18 @@ public async Task Empty_Ghes_Url_Returns_False()
var result = await _service.AreBlobCredentialsRequired("");
result.Should().Be(false);
}

[Fact]
public async Task Ghe_Com_Host_Returns_False()
{
var result = await _service.AreBlobCredentialsRequired("https://github.mycompany.ghe.com/api/v3");
result.Should().Be(false);
}

[Fact]
public async Task Ghe_Com_Host_Does_Not_Call_GetEnterpriseServerVersion()
{
await _service.AreBlobCredentialsRequired("https://github.mycompany.ghe.com/api/v3");
_mockGithubApi.Verify(m => m.GetEnterpriseServerVersion(), Times.Never);
}
}
12 changes: 12 additions & 0 deletions src/gei/Services/GhesVersionChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public virtual async Task<bool> AreBlobCredentialsRequired(string ghesApiUrl)

if (ghesApiUrl.HasValue())
{
if (IsGheHost(ghesApiUrl))
{
_log.LogInformation("Source is a ghe.com host - skipping GHES version check");
return false;
}

blobCredentialsRequired = true;

_log.LogInformation("Using GitHub Enterprise Server - verifying server version");
Expand All @@ -45,4 +51,10 @@ public virtual async Task<bool> AreBlobCredentialsRequired(string ghesApiUrl)

return blobCredentialsRequired;
}

private static bool IsGheHost(string ghesApiUrl)
{
return Uri.TryCreate(ghesApiUrl, UriKind.Absolute, out var uri) &&
uri.Host.EndsWith(".ghe.com", StringComparison.OrdinalIgnoreCase);
}
}
Loading