Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,7 @@ public async Task Reset(string pathToAssetsJson)

if (allowReset)
{
try
{
GitHandler.Run("checkout *", config);
GitHandler.Run("clean -xdf", config);
}
catch(GitProcessException e)
{
HideOrigin(config);
throw GenerateInvokeException(e.Result);
}
Clean(config);

if (!string.IsNullOrWhiteSpace(config.Tag))
{
Expand All @@ -235,6 +226,20 @@ public async Task Reset(string pathToAssetsJson)
HideOrigin(config);
}

private void Clean(GitAssetsConfiguration config)
{
try
{
GitHandler.Run("checkout *", config);
GitHandler.Run("clean -xdf", config);
}
catch (GitProcessException e)
{
HideOrigin(config);
throw GenerateInvokeException(e.Result);
}
}

/// <summary>
/// Given a CommandResult, generate an HttpException.
/// </summary>
Expand Down Expand Up @@ -299,10 +304,16 @@ private void HideOrigin(GitAssetsConfiguration config)
/// <param name="config"></param>
public void CheckoutRepoAtConfig(GitAssetsConfiguration config)
{
// we are already on a targeted tag and as such don't want to discard our recordings
if (Assets.TryGetValue(config.AssetsJsonRelativeLocation.ToString(), out var value) && value == config.Tag)
{
return;
}
// if we are NOT on our targeted tag, before we attempt to switch we need to reset without asking for permission
else
{
Clean(config);
}

var checkoutPaths = ResolveCheckoutPaths(config);

Expand Down