Skip to content

Commit ee74cb1

Browse files
authored
need to ensure that the test-proxy can't destructively update a containing repo directory (#9413)
1 parent 86c24f0 commit ee74cb1

File tree

1 file changed

+19
-2
lines changed
  • tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store

1 file changed

+19
-2
lines changed

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,30 @@ public string[] DetectPendingChanges(GitAssetsConfiguration config)
392392
private void SetOrigin(GitAssetsConfiguration config)
393393
{
394394
var cloneUrl = GetCloneUrl(config.AssetsRepo, config.RepoRoot);
395-
GitHandler.Run($"remote set-url origin {cloneUrl}", config);
395+
396+
// in cases of failure to initialize a real git repo. we need to NOT run git remote set-url
397+
if (config.IsAssetsRepoInitialized())
398+
{
399+
GitHandler.Run($"remote set-url origin {cloneUrl}", config);
400+
}
401+
else
402+
{
403+
_consoleWrapper.WriteLine($"The assets folder within \"{config.AssetsRepoLocation.ToString()}\" was not properly initialized, and as such the proxy is skipping override of the origin url.");
404+
}
396405
}
397406

398407
private void HideOrigin(GitAssetsConfiguration config)
399408
{
400409
var publicOrigin = GetCloneUrl(config.AssetsRepo, config.RepoRoot, honorToken: false);
401-
GitHandler.Run($"remote set-url origin {publicOrigin}", config);
410+
411+
if (config.IsAssetsRepoInitialized())
412+
{
413+
GitHandler.Run($"remote set-url origin {publicOrigin}", config);
414+
}
415+
else
416+
{
417+
_consoleWrapper.WriteLine($"The assets folder within \"{config.AssetsRepoLocation.ToString()}\" was not properly initialized, and as such the proxy is skipping override of the origin url.");
418+
}
402419
}
403420

404421
/// <summary>

0 commit comments

Comments
 (0)