From 8947a5eff2ca54c96c45d47d0f19ddd3861bb82c Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 3 Apr 2024 14:49:07 -0700 Subject: [PATCH 01/12] ensure we fetch and merge main before pushing a new tag --- .../Properties/launchSettings.json | 1 + .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSettings.json b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSettings.json index 77fea943f32..94432d47987 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSettings.json +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSettings.json @@ -2,6 +2,7 @@ "profiles": { "Azure.Sdk.Tools.TestProxy": { "commandName": "Project", + "commandLineArgs": "start --storage-location=\"C:/repo/azure-sdk-for-python/\"", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "Logging__LogLevel__Microsoft": "Information" 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 26acc29ce0c..0be4987f6a8 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -126,9 +126,16 @@ public async Task Push(string pathToAssetsJson) { string gitUserEmail = GetGitOwnerEmail(config); GitHandler.Run($"branch {branchGuid}", config); GitHandler.Run($"checkout {branchGuid}", config); + + // fetch main and merge it + GitHandler.Run($"fetch origin main", config); + GitHandler.Run($"fetch merge --no-edit origin/main", config); + + // add all the recording changes and commit them GitHandler.Run($"add -A .", config); GitHandler.Run($"-c user.name=\"{gitUserName}\" -c user.email=\"{gitUserEmail}\" commit --no-gpg-sign -m \"Automatic asset update from test-proxy.\"", config); - // Get the first 10 digits of the commit SHA. The generatedTagName will be the + + // Get the first 10 digits of the combined SHA. The generatedTagName will be the // config.TagPrefix_ if (GitHandler.TryRun("rev-parse --short=10 HEAD", config.AssetsRepoLocation.ToString(), out CommandResult SHAResult)) { @@ -157,6 +164,7 @@ public async Task Push(string pathToAssetsJson) { HideOrigin(config); // the only executions that have a real chance of failing are + // - merge main // - ls-remote origin // - push // if we have a failure on either of these, we need to unstage our changes for an easy re-attempt at pushing. @@ -547,11 +555,11 @@ public string ResolveCheckoutPaths(GitAssetsConfiguration config) if (combinedPath.ToLower() == AssetsJsonFileName) { - return "./"; + return "./ eng/"; } else { - return combinedPath.Substring(0, combinedPath.Length - (AssetsJsonFileName.Length + 1)); + return combinedPath.Substring(0, combinedPath.Length - (AssetsJsonFileName.Length + 1)) + " eng/"; } } #endregion From 2ad116955df05c985f40924a25734b3c50b8b535 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 3 Apr 2024 15:06:32 -0700 Subject: [PATCH 02/12] what the heck does fetch merge mean --- tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 2 +- 1 file changed, 1 insertion(+), 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 0be4987f6a8..3b525185863 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -129,7 +129,7 @@ public async Task Push(string pathToAssetsJson) { // fetch main and merge it GitHandler.Run($"fetch origin main", config); - GitHandler.Run($"fetch merge --no-edit origin/main", config); + GitHandler.Run($"merge --no-edit origin/main", config); // add all the recording changes and commit them GitHandler.Run($"add -A .", config); From 6b565bb61151f4c88f498709638e12f810923351 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 3 Apr 2024 15:25:38 -0700 Subject: [PATCH 03/12] move the merge _after_ the commit --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 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 3b525185863..2682240a185 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -124,17 +124,20 @@ public async Task Push(string pathToAssetsJson) { string branchGuid = Guid.NewGuid().ToString().Substring(0, 8); string gitUserName = GetGitOwnerName(config); string gitUserEmail = GetGitOwnerEmail(config); + string commitMessage = "Automatic asset update from test-proxy."; + GitHandler.Run($"branch {branchGuid}", config); GitHandler.Run($"checkout {branchGuid}", config); - // fetch main and merge it - GitHandler.Run($"fetch origin main", config); - GitHandler.Run($"merge --no-edit origin/main", config); - // add all the recording changes and commit them GitHandler.Run($"add -A .", config); - GitHandler.Run($"-c user.name=\"{gitUserName}\" -c user.email=\"{gitUserEmail}\" commit --no-gpg-sign -m \"Automatic asset update from test-proxy.\"", config); - + GitHandler.Run($"-c user.name=\"{gitUserName}\" -c user.email=\"{gitUserEmail}\" commit --no-gpg-sign -m \"{commitMessage}\"", config); + + // fetch main and merge it, we must invoke this after the commit for code is complete, otherwise + // we get an error about unmerged changes present when we attempt to merge + GitHandler.Run($"fetch origin main", config); + GitHandler.Run($"merge origin/main -m \"{commitMessage}\"", config); + // Get the first 10 digits of the combined SHA. The generatedTagName will be the // config.TagPrefix_ if (GitHandler.TryRun("rev-parse --short=10 HEAD", config.AssetsRepoLocation.ToString(), out CommandResult SHAResult)) From d6f363882b15fd971b3a8583bdaf8315ddc84bef Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 3 Apr 2024 15:35:40 -0700 Subject: [PATCH 04/12] ensure that the integration merge also has the correct config settings --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 2682240a185..684c2c59cb3 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -124,19 +124,22 @@ public async Task Push(string pathToAssetsJson) { string branchGuid = Guid.NewGuid().ToString().Substring(0, 8); string gitUserName = GetGitOwnerName(config); string gitUserEmail = GetGitOwnerEmail(config); - string commitMessage = "Automatic asset update from test-proxy."; + string assetMessage = "Automatic asset update from test-proxy."; + string mergeMessage = "Automated merge from main for this asset."; + string configurationString = $"-c user.name=\"{gitUserName}\" -c user.email=\"{gitUserEmail}\""; + GitHandler.Run($"branch {branchGuid}", config); GitHandler.Run($"checkout {branchGuid}", config); // add all the recording changes and commit them GitHandler.Run($"add -A .", config); - GitHandler.Run($"-c user.name=\"{gitUserName}\" -c user.email=\"{gitUserEmail}\" commit --no-gpg-sign -m \"{commitMessage}\"", config); + GitHandler.Run($"commit {configurationString} --no-gpg-sign -m \"{assetMessage}\"", config); // fetch main and merge it, we must invoke this after the commit for code is complete, otherwise // we get an error about unmerged changes present when we attempt to merge GitHandler.Run($"fetch origin main", config); - GitHandler.Run($"merge origin/main -m \"{commitMessage}\"", config); + GitHandler.Run($"merge origin/main {configurationString} -m \"{mergeMessage}\"", config); // Get the first 10 digits of the combined SHA. The generatedTagName will be the // config.TagPrefix_ From 8a774fa05a9b877ac1d4ea7c463c8d4be6045965 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 3 Apr 2024 16:52:53 -0700 Subject: [PATCH 05/12] get rid of 'merge' methodology that was pulling in changes that we DID NOT want to deal with --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 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 684c2c59cb3..26b88933324 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -125,21 +125,23 @@ public async Task Push(string pathToAssetsJson) { string gitUserName = GetGitOwnerName(config); string gitUserEmail = GetGitOwnerEmail(config); string assetMessage = "Automatic asset update from test-proxy."; - string mergeMessage = "Automated merge from main for this asset."; string configurationString = $"-c user.name=\"{gitUserName}\" -c user.email=\"{gitUserEmail}\""; GitHandler.Run($"branch {branchGuid}", config); GitHandler.Run($"checkout {branchGuid}", config); + GitHandler.Run($"diff --output=changes.patch --no-color --binary --no-prefix HEAD main -- eng/", config); + GitHandler.Run($"apply --directory=eng/ changes.patch", config); + var pathLocation = Path.Combine(config.AssetsRepoLocation, "changes.patch"); + + if (File.Exists(pathLocation)) { + File.Delete(pathLocation); + } + // add all the recording changes and commit them GitHandler.Run($"add -A .", config); - GitHandler.Run($"commit {configurationString} --no-gpg-sign -m \"{assetMessage}\"", config); - - // fetch main and merge it, we must invoke this after the commit for code is complete, otherwise - // we get an error about unmerged changes present when we attempt to merge - GitHandler.Run($"fetch origin main", config); - GitHandler.Run($"merge origin/main {configurationString} -m \"{mergeMessage}\"", config); + GitHandler.Run($"{configurationString} commit --no-gpg-sign -m \"{assetMessage}\"", config); // Get the first 10 digits of the combined SHA. The generatedTagName will be the // config.TagPrefix_ From 833c57d580ec80e930562b954cde74a3b367a24e Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 3 Apr 2024 16:59:13 -0700 Subject: [PATCH 06/12] restore the launch settings --- .../Properties/launchSettings.json | 1 - .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSettings.json b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSettings.json index 94432d47987..77fea943f32 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSettings.json +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Properties/launchSettings.json @@ -2,7 +2,6 @@ "profiles": { "Azure.Sdk.Tools.TestProxy": { "commandName": "Project", - "commandLineArgs": "start --storage-location=\"C:/repo/azure-sdk-for-python/\"", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "Logging__LogLevel__Microsoft": "Information" 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 26b88933324..db5545960f9 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -127,10 +127,18 @@ public async Task Push(string pathToAssetsJson) { string assetMessage = "Automatic asset update from test-proxy."; string configurationString = $"-c user.name=\"{gitUserName}\" -c user.email=\"{gitUserEmail}\""; - GitHandler.Run($"branch {branchGuid}", config); GitHandler.Run($"checkout {branchGuid}", config); + /* + * This code works by generating a patch file for SPECIFICALLY the eng folder from main. + * Given that these changes appear as "new" changes, they just look like normal file additions. + * This totally eliminates the possibility of weird historical merge if main has code that we don't expect. + * Under azure-sdk-assets, we should never see this, but we have already seen it with specific integration + * test tags under azure-sdk-assets-integration. By keeping it as "patch", the soft RESET on unsuccessful + * push action will properly put their repo into the expected "ready to push" state that a failed + * merge would NOT. + */ GitHandler.Run($"diff --output=changes.patch --no-color --binary --no-prefix HEAD main -- eng/", config); GitHandler.Run($"apply --directory=eng/ changes.patch", config); var pathLocation = Path.Combine(config.AssetsRepoLocation, "changes.patch"); From 9c365467aad44c7bb7e96f832f5492b096627962 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 3 Apr 2024 17:00:33 -0700 Subject: [PATCH 07/12] remove inapplicable comment --- tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 1 - 1 file changed, 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 db5545960f9..c9a6076ead8 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -180,7 +180,6 @@ public async Task Push(string pathToAssetsJson) { HideOrigin(config); // the only executions that have a real chance of failing are - // - merge main // - ls-remote origin // - push // if we have a failure on either of these, we need to unstage our changes for an easy re-attempt at pushing. From 067b5ae70bb684809cc90661b484f446f1c04138 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 3 Apr 2024 17:13:02 -0700 Subject: [PATCH 08/12] handle when the patch is no-op --- tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 5 ++++- 1 file changed, 4 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 c9a6076ead8..0336453ec39 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -140,7 +140,10 @@ public async Task Push(string pathToAssetsJson) { * merge would NOT. */ GitHandler.Run($"diff --output=changes.patch --no-color --binary --no-prefix HEAD main -- eng/", config); - GitHandler.Run($"apply --directory=eng/ changes.patch", config); + if (GitHandler.TryRun($"apply --check --directory=eng/ changes.patch", config.AssetsRepoLocation.ToString(), out var applyResult)) + { + GitHandler.Run($"apply --directory=eng/ changes.patch", config); + } var pathLocation = Path.Combine(config.AssetsRepoLocation, "changes.patch"); if (File.Exists(pathLocation)) { From 76e435c37343a12271737492012ff3b85ecc682d Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 4 Apr 2024 13:58:10 -0700 Subject: [PATCH 09/12] grab gitignore --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 17 +++++++++++++---- 1 file changed, 13 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 0336453ec39..c7a6b6146f7 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -139,15 +139,24 @@ public async Task Push(string pathToAssetsJson) { * push action will properly put their repo into the expected "ready to push" state that a failed * merge would NOT. */ + var engPatchLocation = Path.Combine(config.AssetsRepoLocation, "changes.patch"); GitHandler.Run($"diff --output=changes.patch --no-color --binary --no-prefix HEAD main -- eng/", config); - if (GitHandler.TryRun($"apply --check --directory=eng/ changes.patch", config.AssetsRepoLocation.ToString(), out var applyResult)) + if (GitHandler.TryRun($"apply --check --directory=eng/ changes.patch", config.AssetsRepoLocation.ToString(), out var engPatchResult)) { GitHandler.Run($"apply --directory=eng/ changes.patch", config); } - var pathLocation = Path.Combine(config.AssetsRepoLocation, "changes.patch"); + if (File.Exists(engPatchLocation)) { + File.Delete(engPatchLocation); + } - if (File.Exists(pathLocation)) { - File.Delete(pathLocation); + GitHandler.Run($"diff --output=changes.patch --no-color --binary --no-prefix HEAD main -- .gitignore", config); + if (GitHandler.TryRun($"apply --check changes.patch", config.AssetsRepoLocation.ToString(), out var applyResult)) + { + GitHandler.Run($"apply changes.patch", config); + } + if (File.Exists(engPatchLocation)) + { + File.Delete(engPatchLocation); } // add all the recording changes and commit them From f46774ce8dad777b80d4eb5e66c93dea09293532 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 4 Apr 2024 16:50:53 -0700 Subject: [PATCH 10/12] repair the tests --- .../Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs index 96abbca37ef..207c2930012 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs @@ -438,10 +438,10 @@ public async Task UpdateRecordingJsonUpdatesProperly() } [Theory] - [InlineData("assets.json", false, "./")] - [InlineData("assets.json", true, "python/recordings")] - [InlineData("sdk/storage/assets.json", false, "sdk/storage")] - [InlineData("sdk/storage/assets.json", true, "python/recordings/sdk/storage")] + [InlineData("assets.json", false, "./ eng/")] + [InlineData("assets.json", true, "python/recordings eng/")] + [InlineData("sdk/storage/assets.json", false, "sdk/storage eng/")] + [InlineData("sdk/storage/assets.json", true, "python/recordings/sdk/storage eng/")] public async Task ResolveCheckPathsResolvesProperly(string assetsJsonPath, bool includePrefix, string expectedResult) { var expectedPaths = new string[] From 7cfcc912fb142bd1e60294f64b2b8ca157e9b31f Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 4 Apr 2024 17:32:56 -0700 Subject: [PATCH 11/12] ensure that the root file properly applies --- .../Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs | 8 ++++---- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs index 207c2930012..a1426353a84 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/GitStoreTests.cs @@ -438,10 +438,10 @@ public async Task UpdateRecordingJsonUpdatesProperly() } [Theory] - [InlineData("assets.json", false, "./ eng/")] - [InlineData("assets.json", true, "python/recordings eng/")] - [InlineData("sdk/storage/assets.json", false, "sdk/storage eng/")] - [InlineData("sdk/storage/assets.json", true, "python/recordings/sdk/storage eng/")] + [InlineData("assets.json", false, "./ eng/ .gitignore")] + [InlineData("assets.json", true, "python/recordings eng/ .gitignore")] + [InlineData("sdk/storage/assets.json", false, "sdk/storage eng/ .gitignore")] + [InlineData("sdk/storage/assets.json", true, "python/recordings/sdk/storage eng/ .gitignore")] public async Task ResolveCheckPathsResolvesProperly(string assetsJsonPath, bool includePrefix, string expectedResult) { var expectedPaths = new string[] 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 c7a6b6146f7..20ad785aedd 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -149,7 +149,7 @@ public async Task Push(string pathToAssetsJson) { File.Delete(engPatchLocation); } - GitHandler.Run($"diff --output=changes.patch --no-color --binary --no-prefix HEAD main -- .gitignore", config); + GitHandler.Run($"diff --output=changes.patch --no-color --binary HEAD main -- .gitignore", config); if (GitHandler.TryRun($"apply --check changes.patch", config.AssetsRepoLocation.ToString(), out var applyResult)) { GitHandler.Run($"apply changes.patch", config); @@ -582,11 +582,11 @@ public string ResolveCheckoutPaths(GitAssetsConfiguration config) if (combinedPath.ToLower() == AssetsJsonFileName) { - return "./ eng/"; + return "./ eng/ .gitignore"; } else { - return combinedPath.Substring(0, combinedPath.Length - (AssetsJsonFileName.Length + 1)) + " eng/"; + return combinedPath.Substring(0, combinedPath.Length - (AssetsJsonFileName.Length + 1)) + " eng/ .gitignore"; } } #endregion From 8ce22ac90a0b1617817e5b0516e982868d572f89 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Fri, 5 Apr 2024 16:45:05 -0700 Subject: [PATCH 12/12] reset --soft was firing when we were unable to retrieve main properly. definitely don't want that to be the case --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 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 20ad785aedd..69e0a5dd52f 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -116,6 +116,7 @@ public async Task Push(string pathToAssetsJson) { SetOrigin(config); var pendingChanges = DetectPendingChanges(config); var generatedTagName = config.TagPrefix; + bool codeCommitted = false; if (pendingChanges.Length > 0) { @@ -162,6 +163,7 @@ public async Task Push(string pathToAssetsJson) { // add all the recording changes and commit them GitHandler.Run($"add -A .", config); GitHandler.Run($"{configurationString} commit --no-gpg-sign -m \"{assetMessage}\"", config); + codeCommitted = true; // Get the first 10 digits of the combined SHA. The generatedTagName will be the // config.TagPrefix_ @@ -191,11 +193,15 @@ public async Task Push(string pathToAssetsJson) { { HideOrigin(config); - // the only executions that have a real chance of failing are - // - ls-remote origin - // - push - // if we have a failure on either of these, we need to unstage our changes for an easy re-attempt at pushing. - GitHandler.TryRun("reset --soft HEAD^", config.AssetsRepoLocation.ToString(), out CommandResult ResetResult); + // we should not reset soft if we haven't ever committed. + if (codeCommitted) + { + // the only executions that have a real chance of failing are + // - ls-remote origin + // - push + // if we have a failure on either of these, we need to unstage our changes for an easy re-attempt at pushing. + GitHandler.TryRun("reset --soft HEAD^", config.AssetsRepoLocation.ToString(), out CommandResult ResetResult); + } throw GenerateInvokeException(e.Result); }