From 2a1a0ee4e662c369420fc06abfe872ec270a865b Mon Sep 17 00:00:00 2001 From: Tiago Pascoal Date: Thu, 26 Oct 2023 16:44:38 +0100 Subject: [PATCH 1/7] Add capability to skip version checks If environment variable GEI_SKIP_VERSION_CHECK is set true, no version checks will be performed --- README.md | 4 ++++ RELEASENOTES.md | 2 +- src/ado2gh/Program.cs | 6 ++++++ src/bbs2gh/Program.cs | 6 ++++++ src/gei/Program.cs | 6 ++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e9dfe587c..757eab685 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 CLIs are launched, they perform a check to ensure that the latest version is being used and will display a warning message if this is not the case. However, if you wish to skip this check, you can do so by setting the `GEI_SKIP_VERSION_CHECK`` environment variable to true. This will prevent the CLIs from checking for the latest version on startup and displaying a warning message. + ## Contributions See [Contributing](CONTRIBUTING.md) for more info on how to get involved. diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 8b1378917..70073c874 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1 +1 @@ - +- Skip version checking on startup if environment variable `GEI_SKIP_VERSION_CHECK` is set to true. diff --git a/src/ado2gh/Program.cs b/src/ado2gh/Program.cs index 716090909..5263c8644 100644 --- a/src/ado2gh/Program.cs +++ b/src/ado2gh/Program.cs @@ -106,6 +106,12 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { + if (Environment.GetEnvironmentVariable("GEI_SKIP_VERSION_CHECK")?.ToUpperInvariant() == "TRUE") + { + Logger.LogInformation("Skipped latest version check of the ado2gh CLI"); + return; + } + var versionChecker = sp.GetRequiredService(); if (await versionChecker.IsLatest()) diff --git a/src/bbs2gh/Program.cs b/src/bbs2gh/Program.cs index 6c62dc37c..50d55121b 100644 --- a/src/bbs2gh/Program.cs +++ b/src/bbs2gh/Program.cs @@ -113,6 +113,12 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { + if (Environment.GetEnvironmentVariable("GEI_SKIP_VERSION_CHECK")?.ToUpperInvariant() == "TRUE") + { + Logger.LogInformation("Skipped latest version check of the bbs2gh extension"); + return; + } + var versionChecker = sp.GetRequiredService(); if (await versionChecker.IsLatest()) diff --git a/src/gei/Program.cs b/src/gei/Program.cs index e31c73704..93128aa4a 100644 --- a/src/gei/Program.cs +++ b/src/gei/Program.cs @@ -106,6 +106,12 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { + if (Environment.GetEnvironmentVariable("GEI_SKIP_VERSION_CHECK")?.ToUpperInvariant() == "TRUE") + { + Logger.LogInformation("Skipped latest version check of the gei CLI "); + return; + } + var versionChecker = sp.GetRequiredService(); if (await versionChecker.IsLatest()) From 0c80630cbd3bec99e5dad186eb408fb17dc0960d Mon Sep 17 00:00:00 2001 From: Tiago Pascoal Date: Thu, 26 Oct 2023 17:11:41 +0100 Subject: [PATCH 2/7] Remove spurious back tick on readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 757eab685..63b43d365 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Refer to the [official documentation](https://docs.github.com/en/migrations/usin ### Skipping version checks -When the CLIs are launched, they perform a check to ensure that the latest version is being used and will display a warning message if this is not the case. However, if you wish to skip this check, you can do so by setting the `GEI_SKIP_VERSION_CHECK`` environment variable to true. This will prevent the CLIs from checking for the latest version on startup and displaying a warning message. +When the CLIs are launched, they perform a check to ensure that the latest version is being used and will display a warning message if this is not the case. However, if you wish to skip this check, you can do so by setting the `GEI_SKIP_VERSION_CHECK` environment variable to true. This will prevent the CLIs from checking for the latest version on startup and displaying a warning message. ## Contributions From 0c1f887d771752f80166166435533604b5b856ee Mon Sep 17 00:00:00 2001 From: Tiago Pascoal Date: Tue, 31 Oct 2023 14:01:02 +0000 Subject: [PATCH 3/7] Use EnvironmentVariable provider instead of accessing environment directly --- src/Octoshift/Services/EnvironmentVariableProvider.cs | 4 ++++ .../Octoshift/Services/EnvironmentVariableProviderTests.cs | 2 ++ src/ado2gh/Program.cs | 4 +++- src/bbs2gh/Program.cs | 4 +++- src/gei/Program.cs | 4 +++- 5 files changed, 15 insertions(+), 3 deletions(-) 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 5a15f6292..370e54236 100644 --- a/src/ado2gh/Program.cs +++ b/src/ado2gh/Program.cs @@ -114,7 +114,9 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { - if (Environment.GetEnvironmentVariable("GEI_SKIP_VERSION_CHECK")?.ToUpperInvariant() == "TRUE") + var envProvider = sp.GetRequiredService(); + + if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { Logger.LogInformation("Skipped latest version check of the ado2gh CLI"); return; diff --git a/src/bbs2gh/Program.cs b/src/bbs2gh/Program.cs index dfed5b47e..cc759a676 100644 --- a/src/bbs2gh/Program.cs +++ b/src/bbs2gh/Program.cs @@ -121,7 +121,9 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { - if (Environment.GetEnvironmentVariable("GEI_SKIP_VERSION_CHECK")?.ToUpperInvariant() == "TRUE") + var envProvider = sp.GetRequiredService(); + + if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { Logger.LogInformation("Skipped latest version check of the bbs2gh extension"); return; diff --git a/src/gei/Program.cs b/src/gei/Program.cs index d155f01d7..c2e0c2eaa 100644 --- a/src/gei/Program.cs +++ b/src/gei/Program.cs @@ -114,7 +114,9 @@ private static async Task GithubStatusCheck(ServiceProvider sp) private static async Task LatestVersionCheck(ServiceProvider sp) { - if (Environment.GetEnvironmentVariable("GEI_SKIP_VERSION_CHECK")?.ToUpperInvariant() == "TRUE") + var envProvider = sp.GetRequiredService(); + + if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { Logger.LogInformation("Skipped latest version check of the gei CLI "); return; From f32f5ec8bb0117f15ffd69b7bd01cfac13d0fcc7 Mon Sep 17 00:00:00 2001 From: Tiago Pascoal Date: Tue, 31 Oct 2023 14:06:52 +0000 Subject: [PATCH 4/7] Changed skipped version check log message for consistency with skip status check --- src/ado2gh/Program.cs | 2 +- src/bbs2gh/Program.cs | 2 +- src/gei/Program.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ado2gh/Program.cs b/src/ado2gh/Program.cs index 370e54236..8243b8bad 100644 --- a/src/ado2gh/Program.cs +++ b/src/ado2gh/Program.cs @@ -118,7 +118,7 @@ private static async Task LatestVersionCheck(ServiceProvider sp) if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { - Logger.LogInformation("Skipped latest version check of the ado2gh CLI"); + Logger.LogInformation("Skipped latest version check of the ado2gh CLI due to GEI_VERSION_CHECK environment variable"); return; } diff --git a/src/bbs2gh/Program.cs b/src/bbs2gh/Program.cs index cc759a676..05d39b6ae 100644 --- a/src/bbs2gh/Program.cs +++ b/src/bbs2gh/Program.cs @@ -125,7 +125,7 @@ private static async Task LatestVersionCheck(ServiceProvider sp) if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { - Logger.LogInformation("Skipped latest version check of the bbs2gh extension"); + Logger.LogInformation("Skipped latest version check of the bbs2gh extension due to GEI_VERSION_CHECK environment variable"); return; } diff --git a/src/gei/Program.cs b/src/gei/Program.cs index c2e0c2eaa..bc00aacd7 100644 --- a/src/gei/Program.cs +++ b/src/gei/Program.cs @@ -118,7 +118,7 @@ private static async Task LatestVersionCheck(ServiceProvider sp) if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { - Logger.LogInformation("Skipped latest version check of the gei CLI "); + Logger.LogInformation("Skipped latest version check of the gei CLI due to GEI_VERSION_CHECK environment variable"); return; } From 181fb0f48b4660ca0bc099e7f8f45f7a263c379f Mon Sep 17 00:00:00 2001 From: Tiago Pascoal Date: Tue, 31 Oct 2023 20:16:09 +0000 Subject: [PATCH 5/7] Apply suggestions from @timrogers code review Co-authored-by: Tim Rogers --- README.md | 2 +- src/ado2gh/Program.cs | 2 +- src/bbs2gh/Program.cs | 2 +- src/gei/Program.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cf2067b35..98ec1e634 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Refer to the [official documentation](https://docs.github.com/en/migrations/usin ### Skipping version checks -When the CLIs are launched, they perform a check to ensure that the latest version is being used and will display a warning message if this is not the case. However, if you wish to skip this check, you can do so by setting the `GEI_SKIP_VERSION_CHECK` environment variable to true. This will prevent the CLIs from checking for the latest version on startup and displaying a warning message. +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 diff --git a/src/ado2gh/Program.cs b/src/ado2gh/Program.cs index 8243b8bad..4a88d6857 100644 --- a/src/ado2gh/Program.cs +++ b/src/ado2gh/Program.cs @@ -118,7 +118,7 @@ private static async Task LatestVersionCheck(ServiceProvider sp) if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { - Logger.LogInformation("Skipped latest version check of the ado2gh CLI due to GEI_VERSION_CHECK environment variable"); + Logger.LogInformation("Skipped latest version check due to GEI_VERSION_CHECK environment variable"); return; } diff --git a/src/bbs2gh/Program.cs b/src/bbs2gh/Program.cs index 05d39b6ae..339bcd309 100644 --- a/src/bbs2gh/Program.cs +++ b/src/bbs2gh/Program.cs @@ -125,7 +125,7 @@ private static async Task LatestVersionCheck(ServiceProvider sp) if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { - Logger.LogInformation("Skipped latest version check of the bbs2gh extension due to GEI_VERSION_CHECK environment variable"); + Logger.LogInformation("Skipped latest version check due to GEI_VERSION_CHECK environment variable"); return; } diff --git a/src/gei/Program.cs b/src/gei/Program.cs index bc00aacd7..4995978ef 100644 --- a/src/gei/Program.cs +++ b/src/gei/Program.cs @@ -118,7 +118,7 @@ private static async Task LatestVersionCheck(ServiceProvider sp) if (envProvider.SkipVersionCheck()?.ToUpperInvariant() is "TRUE" or "1") { - Logger.LogInformation("Skipped latest version check of the gei CLI due to GEI_VERSION_CHECK environment variable"); + Logger.LogInformation("Skipped latest version check due to GEI_VERSION_CHECK environment variable"); return; } From 31592ceb643feeb7dcbc055232e88d08e97ea5be Mon Sep 17 00:00:00 2001 From: Tiago Pascoal Date: Tue, 31 Oct 2023 20:16:33 +0000 Subject: [PATCH 6/7] Update RELEASENOTES.md Co-authored-by: Tim Rogers --- RELEASENOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 45c1ffb99..328388f17 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,3 +1,3 @@ -- Skip version checking on startup if environment variable `GEI_SKIP_VERSION_CHECK` is set to true. +- Skip last version check on startup if environment variable `GEI_SKIP_VERSION_CHECK` is set to `true` - Skip GitHub status checking on startup if environment variable `GEI_SKIP_STATUS_CHECK` is set to true. From bfa0e53013e54c08feab39462bb3534ab942b80d Mon Sep 17 00:00:00 2001 From: Tiago Pascoal Date: Wed, 6 Dec 2023 15:04:21 +0000 Subject: [PATCH 7/7] Update RELEASENOTES.md Co-authored-by: Tim Rogers --- RELEASENOTES.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 328388f17..b35d61ff8 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,3 +1,2 @@ -- Skip last version check on startup if environment variable `GEI_SKIP_VERSION_CHECK` is set to `true` -- Skip GitHub status checking on startup if environment variable `GEI_SKIP_STATUS_CHECK` is set to true. +- Skip latest version check on startup if environment variable `GEI_SKIP_VERSION_CHECK` is set to `true`