From 03a3d7d173ac3684fb8204cf8b372b059218badb Mon Sep 17 00:00:00 2001 From: Scott Beddall Date: Thu, 2 Jun 2022 16:07:35 -0700 Subject: [PATCH 1/6] ensure conditions all work properly in the case of a previous error --- eng/common/pipelines/templates/steps/credscan.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eng/common/pipelines/templates/steps/credscan.yml b/eng/common/pipelines/templates/steps/credscan.yml index 0171c79d0d2..8a2e53748ab 100644 --- a/eng/common/pipelines/templates/steps/credscan.yml +++ b/eng/common/pipelines/templates/steps/credscan.yml @@ -28,6 +28,8 @@ steps: Write-Host "##vso[task.setvariable variable=SKIP_CREDSCAN]true" } displayName: CredScan setup + condition: succeededOrFailed() + - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3 displayName: CredScan running condition: and(succeededOrFailed(), ne(variables['SKIP_CREDSCAN'], true)) From 067c88ee4f2818166e09d437b9d15bf73ec4c39c Mon Sep 17 00:00:00 2001 From: Scott Beddall Date: Fri, 27 Jan 2023 10:09:54 -0800 Subject: [PATCH 2/6] enable terminal prompts by default? --- tools/test-proxy/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/test-proxy/tests.yml b/tools/test-proxy/tests.yml index 8457c01dd3a..e7ce78aadb2 100644 --- a/tools/test-proxy/tests.yml +++ b/tools/test-proxy/tests.yml @@ -36,6 +36,7 @@ stages: GIT_TOKEN: $(azuresdk-github-pat) GIT_COMMIT_OWNER: azure-sdk GIT_COMMIT_EMAIL: azuresdk@microsoft.com + GIT_TERMINAL_PROMPT: 1 - task: PublishTestResults@2 condition: succeededOrFailed() @@ -78,6 +79,7 @@ stages: GIT_TOKEN: $(azuresdk-github-pat) GIT_COMMIT_OWNER: azure-sdk GIT_COMMIT_EMAIL: azuresdk@microsoft.com + GIT_TERMINAL_PROMPT: 1 - job: Docker_CLI_Integration_Test From c31d3a8f52d8656dd9f5cd569536b0f363ef36b3 Mon Sep 17 00:00:00 2001 From: Scott Beddall Date: Fri, 27 Jan 2023 10:29:39 -0800 Subject: [PATCH 3/6] try making the status include the user and email --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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..2b98bd5e054 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -249,7 +249,17 @@ public string[] DetectPendingChanges(GitAssetsConfiguration config) { SetSafeDirectory(config); - if (!GitHandler.TryRun("status --porcelain", config.AssetsRepoLocation.ToString(), out var diffResult)) + var a = Environment.GetEnvironmentVariable(GIT_COMMIT_OWNER_ENV_VAR); + var b = Environment.GetEnvironmentVariable(GIT_COMMIT_EMAIL_ENV_VAR); + + var preface = ""; + if (null != a && null != b) + { + preface = $"-c user.name =\"{a}\" -c user.email=\"{b}\" "; + } + + var run = $"{preface}status --porcelain"; + if (!GitHandler.TryRun($"status --porcelain", config.AssetsRepoLocation.ToString(), out var diffResult)) { throw GenerateInvokeException(diffResult); } From ec05bd11337312882f8e281fab7a701a07419861 Mon Sep 17 00:00:00 2001 From: Scott Beddall Date: Fri, 27 Jan 2023 11:03:23 -0800 Subject: [PATCH 4/6] try to set the origin before detecting pending chnages --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 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 2b98bd5e054..d0870c96f86 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,7 +122,6 @@ public async Task Push(string pathToAssetsJson) { { throw GenerateInvokeException(SHAResult); } - SetOrigin(config); GitHandler.Run($"tag {generatedTagName}", config); GitHandler.Run($"push origin {generatedTagName}", config); @@ -173,6 +173,7 @@ public async Task Reset(string pathToAssetsJson) InitializeAssetsRepo(config); } + SetOrigin(config); var pendingChanges = DetectPendingChanges(config); if (pendingChanges.Length > 0) @@ -217,6 +218,8 @@ public async Task Reset(string pathToAssetsJson) await BreadCrumb.Update(config); } } + + HideOrigin(config); } /// @@ -249,16 +252,6 @@ public string[] DetectPendingChanges(GitAssetsConfiguration config) { SetSafeDirectory(config); - var a = Environment.GetEnvironmentVariable(GIT_COMMIT_OWNER_ENV_VAR); - var b = Environment.GetEnvironmentVariable(GIT_COMMIT_EMAIL_ENV_VAR); - - var preface = ""; - if (null != a && null != b) - { - preface = $"-c user.name =\"{a}\" -c user.email=\"{b}\" "; - } - - var run = $"{preface}status --porcelain"; if (!GitHandler.TryRun($"status --porcelain", config.AssetsRepoLocation.ToString(), out var diffResult)) { throw GenerateInvokeException(diffResult); From a3a5fdd8d36ea32004225262b16a658861c9cd57 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Fri, 27 Jan 2023 14:34:35 -0800 Subject: [PATCH 5/6] 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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 d0870c96f86..7c2c8440667 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -125,15 +125,17 @@ public async Task Push(string pathToAssetsJson) { 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); } /// @@ -209,6 +211,7 @@ public async Task Reset(string pathToAssetsJson) } catch(GitProcessException e) { + HideOrigin(config); throw GenerateInvokeException(e.Result); } @@ -312,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); } } From eba9eaedf179fa3ec0d7205b22cbf8e682391fd1 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Fri, 27 Jan 2023 14:37:50 -0800 Subject: [PATCH 6/6] remove env var changes --- tools/test-proxy/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/test-proxy/tests.yml b/tools/test-proxy/tests.yml index e7ce78aadb2..8457c01dd3a 100644 --- a/tools/test-proxy/tests.yml +++ b/tools/test-proxy/tests.yml @@ -36,7 +36,6 @@ stages: GIT_TOKEN: $(azuresdk-github-pat) GIT_COMMIT_OWNER: azure-sdk GIT_COMMIT_EMAIL: azuresdk@microsoft.com - GIT_TERMINAL_PROMPT: 1 - task: PublishTestResults@2 condition: succeededOrFailed() @@ -79,7 +78,6 @@ stages: GIT_TOKEN: $(azuresdk-github-pat) GIT_COMMIT_OWNER: azure-sdk GIT_COMMIT_EMAIL: azuresdk@microsoft.com - GIT_TERMINAL_PROMPT: 1 - job: Docker_CLI_Integration_Test