diff --git a/README.md b/README.md index 3fbfd08e7..98ec1e634 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,10 @@ Refer to the [official documentation](https://docs.github.com/en/migrations/usin Refer to the [official documentation](https://docs.github.com/en/migrations/using-github-enterprise-importer/migrating-repositories-with-github-enterprise-importer/migrating-repositories-from-bitbucket-server-to-github-enterprise-cloud) for more details. +### Skipping version checks + +When the CLI is launched, it logs if a newer version of the CLI is available. You can skip this check by setting the `GEI_SKIP_VERSION_CHECK` environment variable to `true`. + ### Skipping GitHub status checks When the CLI is launched, it logs a warning if there are any ongoing [GitHub incidents](https://www.githubstatus.com/) that might affect your use of the CLI. You can skip this check by setting the `GEI_SKIP_STATUS_CHECK` environment variable to `true`. diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 8b1378917..b35d61ff8 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1 +1,2 @@ +- Skip latest version check on startup if environment variable `GEI_SKIP_VERSION_CHECK` is set to `true` diff --git a/src/Octoshift/Services/EnvironmentVariableProvider.cs b/src/Octoshift/Services/EnvironmentVariableProvider.cs index ea82647d4..b68cbc4b7 100644 --- a/src/Octoshift/Services/EnvironmentVariableProvider.cs +++ b/src/Octoshift/Services/EnvironmentVariableProvider.cs @@ -17,6 +17,7 @@ public class EnvironmentVariableProvider private const string BBS_PASSWORD = "BBS_PASSWORD"; private const string SMB_PASSWORD = "SMB_PASSWORD"; private const string GEI_SKIP_STATUS_CHECK = "GEI_SKIP_STATUS_CHECK"; + private const string GEI_SKIP_VERSION_CHECK = "GEI_SKIP_VERSION_CHECK"; private readonly OctoLogger _logger; @@ -61,6 +62,9 @@ public virtual string SmbPassword(bool throwIfNotFound = true) => public virtual string SkipStatusCheck(bool throwIfNotFound = false) => GetValue(GEI_SKIP_STATUS_CHECK, throwIfNotFound); + public virtual string SkipVersionCheck(bool throwIfNotFound = false) => + GetValue(GEI_SKIP_VERSION_CHECK, throwIfNotFound); + private string GetValue(string name, bool throwIfNotFound) { var value = Environment.GetEnvironmentVariable(name); diff --git a/src/OctoshiftCLI.Tests/Octoshift/Services/EnvironmentVariableProviderTests.cs b/src/OctoshiftCLI.Tests/Octoshift/Services/EnvironmentVariableProviderTests.cs index 45bf17528..7ee2a668d 100644 --- a/src/OctoshiftCLI.Tests/Octoshift/Services/EnvironmentVariableProviderTests.cs +++ b/src/OctoshiftCLI.Tests/Octoshift/Services/EnvironmentVariableProviderTests.cs @@ -18,6 +18,7 @@ public class EnvironmentVariableProviderTests private const string BBS_USERNAME = "BBS_USERNAME"; private const string BBS_PASSWORD = "BBS_PASSWORD"; private const string GEI_SKIP_STATUS_CHECK = "GEI_SKIP_STATUS_CHECK"; + private const string GEI_SKIP_VERSION_CHECK = "GEI_SKIP_VERSION_CHECK"; private readonly EnvironmentVariableProvider _environmentVariableProvider; private readonly Mock _mockLogger = TestHelpers.CreateMock(); @@ -154,5 +155,6 @@ private void ResetEnvs() Environment.SetEnvironmentVariable(BBS_USERNAME, null); Environment.SetEnvironmentVariable(BBS_PASSWORD, null); Environment.SetEnvironmentVariable(GEI_SKIP_STATUS_CHECK, null); + Environment.SetEnvironmentVariable(GEI_SKIP_VERSION_CHECK, null); } } diff --git a/src/ado2gh/Program.cs b/src/ado2gh/Program.cs index a7adcc25e..4a88d6857 100644 --- a/src/ado2gh/Program.cs +++ b/src/ado2gh/Program.cs @@ -114,6 +114,14 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { + var envProvider = sp.GetRequiredService(); + + if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") + { + Logger.LogInformation("Skipped latest version check due to GEI_VERSION_CHECK environment variable"); + return; + } + var versionChecker = sp.GetRequiredService(); if (await versionChecker.IsLatest()) diff --git a/src/bbs2gh/Program.cs b/src/bbs2gh/Program.cs index c18119082..339bcd309 100644 --- a/src/bbs2gh/Program.cs +++ b/src/bbs2gh/Program.cs @@ -121,6 +121,14 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { + var envProvider = sp.GetRequiredService(); + + if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") + { + Logger.LogInformation("Skipped latest version check due to GEI_VERSION_CHECK environment variable"); + return; + } + var versionChecker = sp.GetRequiredService(); if (await versionChecker.IsLatest()) diff --git a/src/gei/Program.cs b/src/gei/Program.cs index 4e246580a..4995978ef 100644 --- a/src/gei/Program.cs +++ b/src/gei/Program.cs @@ -114,6 +114,14 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { + var envProvider = sp.GetRequiredService(); + + if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") + { + Logger.LogInformation("Skipped latest version check due to GEI_VERSION_CHECK environment variable"); + return; + } + var versionChecker = sp.GetRequiredService(); if (await versionChecker.IsLatest())