From ff66b2a5e6d1af11f49d05541c5f239bea4b2189 Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:26:16 -0800 Subject: [PATCH] Repair failing test-proxy livetests (#5259) * try to set the origin before detecting pending chnages * ensure that we properly hide the origin url before exiting (so we don't leave stuff around accidentally) --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs index c2b6deb87cc..7c2c8440667 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -97,6 +97,7 @@ public async Task Push(string pathToAssetsJson) { return; } + SetOrigin(config); var pendingChanges = DetectPendingChanges(config); var generatedTagName = config.TagPrefix; @@ -121,19 +122,20 @@ public async Task Push(string pathToAssetsJson) { { throw GenerateInvokeException(SHAResult); } - SetOrigin(config); GitHandler.Run($"tag {generatedTagName}", config); GitHandler.Run($"push origin {generatedTagName}", config); - HideOrigin(config); } catch(GitProcessException e) { + HideOrigin(config); throw GenerateInvokeException(e.Result); } await UpdateAssetsJson(generatedTagName, config); await BreadCrumb.Update(config); } + + HideOrigin(config); } /// @@ -173,6 +175,7 @@ public async Task Reset(string pathToAssetsJson) InitializeAssetsRepo(config); } + SetOrigin(config); var pendingChanges = DetectPendingChanges(config); if (pendingChanges.Length > 0) @@ -208,6 +211,7 @@ public async Task Reset(string pathToAssetsJson) } catch(GitProcessException e) { + HideOrigin(config); throw GenerateInvokeException(e.Result); } @@ -217,6 +221,8 @@ public async Task Reset(string pathToAssetsJson) await BreadCrumb.Update(config); } } + + HideOrigin(config); } /// @@ -249,7 +255,7 @@ public string[] DetectPendingChanges(GitAssetsConfiguration config) { SetSafeDirectory(config); - if (!GitHandler.TryRun("status --porcelain", config.AssetsRepoLocation.ToString(), out var diffResult)) + if (!GitHandler.TryRun($"status --porcelain", config.AssetsRepoLocation.ToString(), out var diffResult)) { throw GenerateInvokeException(diffResult); } @@ -309,16 +315,18 @@ public void CheckoutRepoAtConfig(GitAssetsConfiguration config) // The -c advice.detachedHead=false removes the verbose detatched head state // warning that happens when syncing sparse-checkout to a particular Tag GitHandler.Run($"-c advice.detachedHead=false checkout {config.Tag}", config); - HideOrigin(config); // the first argument, the key, is the path to the assets json relative location // the second argument, the value, is the value we want to set the json elative location to // the third argument is a function argument that resolves what to do in the "update" case. If the key already exists // update the tag to what we just checked out. Assets.AddOrUpdate(config.AssetsJsonRelativeLocation.ToString(), config.Tag, (key, oldValue) => config.Tag); + + HideOrigin(config); } catch(GitProcessException e) { + HideOrigin(config); throw GenerateInvokeException(e.Result); } }