Skip to content

Commit

Permalink
Merge pull request #1154 from tspascoal/skip-versioncheck
Browse files Browse the repository at this point in the history
Add capability to skip version checks
  • Loading branch information
timrogers authored Dec 6, 2023
2 parents 7bdc205 + bfa0e53 commit b3cd3ae
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

- Skip latest version check on startup if environment variable `GEI_SKIP_VERSION_CHECK` is set to `true`
4 changes: 4 additions & 0 deletions src/Octoshift/Services/EnvironmentVariableProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<OctoLogger> _mockLogger = TestHelpers.CreateMock<OctoLogger>();
Expand Down Expand Up @@ -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);
}
}
8 changes: 8 additions & 0 deletions src/ado2gh/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ private static async Task GithubStatusCheck(ServiceProvider sp)

private static async Task LatestVersionCheck(ServiceProvider sp)
{
var envProvider = sp.GetRequiredService<EnvironmentVariableProvider>();

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<VersionChecker>();

if (await versionChecker.IsLatest())
Expand Down
8 changes: 8 additions & 0 deletions src/bbs2gh/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ private static async Task GithubStatusCheck(ServiceProvider sp)

private static async Task LatestVersionCheck(ServiceProvider sp)
{
var envProvider = sp.GetRequiredService<EnvironmentVariableProvider>();

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<VersionChecker>();

if (await versionChecker.IsLatest())
Expand Down
8 changes: 8 additions & 0 deletions src/gei/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ private static async Task GithubStatusCheck(ServiceProvider sp)

private static async Task LatestVersionCheck(ServiceProvider sp)
{
var envProvider = sp.GetRequiredService<EnvironmentVariableProvider>();

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<VersionChecker>();

if (await versionChecker.IsLatest())
Expand Down

0 comments on commit b3cd3ae

Please sign in to comment.