Skip to content

Commit

Permalink
Repair failing test-proxy livetests (#5259)
Browse files Browse the repository at this point in the history
* try to set the origin before detecting pending chnages
* ensure that we properly hide the origin url before exiting (so we don't leave stuff around accidentally)
  • Loading branch information
scbedd authored Jan 31, 2023
1 parent 01fc067 commit ff66b2a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public async Task Push(string pathToAssetsJson) {
return;
}

SetOrigin(config);
var pendingChanges = DetectPendingChanges(config);
var generatedTagName = config.TagPrefix;

Expand All @@ -121,19 +122,20 @@ public async Task Push(string pathToAssetsJson) {
{
throw GenerateInvokeException(SHAResult);
}
SetOrigin(config);

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);
}

/// <summary>
Expand Down Expand Up @@ -173,6 +175,7 @@ public async Task Reset(string pathToAssetsJson)
InitializeAssetsRepo(config);
}

SetOrigin(config);
var pendingChanges = DetectPendingChanges(config);

if (pendingChanges.Length > 0)
Expand Down Expand Up @@ -208,6 +211,7 @@ public async Task Reset(string pathToAssetsJson)
}
catch(GitProcessException e)
{
HideOrigin(config);
throw GenerateInvokeException(e.Result);
}

Expand All @@ -217,6 +221,8 @@ public async Task Reset(string pathToAssetsJson)
await BreadCrumb.Update(config);
}
}

HideOrigin(config);
}

/// <summary>
Expand Down Expand Up @@ -249,7 +255,7 @@ public string[] DetectPendingChanges(GitAssetsConfiguration config)
{
SetSafeDirectory(config);

if (!GitHandler.TryRun("status --porcelain", config.AssetsRepoLocation.ToString(), out var diffResult))
if (!GitHandler.TryRun($"status --porcelain", config.AssetsRepoLocation.ToString(), out var diffResult))
{
throw GenerateInvokeException(diffResult);
}
Expand Down Expand Up @@ -309,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);
}
}
Expand Down

0 comments on commit ff66b2a

Please sign in to comment.