From 723daf990783f6a15f2e7490ef1effa4c0fe2633 Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Mon, 5 Dec 2022 15:01:27 -0800 Subject: [PATCH] Ensure `push` of an unrestored `assets.json` is a recognizable error (#4868) * and set environment exit code to -1 --- .../Azure.Sdk.Tools.TestProxy/Store/GitStore.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 df96bdc5469..94a540815f4 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -85,6 +85,18 @@ public async Task GetPath(string pathToAssetsJson) /// public async Task Push(string pathToAssetsJson) { var config = await ParseConfigurationFile(pathToAssetsJson); + + var initialized = IsAssetsRepoInitialized(config); + + if (!initialized) + { + _consoleWrapper.WriteLine($"The targeted assets.json \"{config.AssetsJsonRelativeLocation}\" has not been restored prior to attempting push. " + + $"Are you certain you're pushing the correct assets.json? Please invoke \'test-proxy restore \"{config.AssetsJsonRelativeLocation}\"\' prior to invoking a push operation."); + + Environment.ExitCode = -1; + return; + } + var pendingChanges = DetectPendingChanges(config); var generatedTagName = config.TagPrefix;