Skip to content

Commit

Permalink
update the entry to catch git config errors before the push happens (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
scbedd authored Jul 30, 2024
1 parent f3e3a51 commit 63a5f57
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions eng/common/testproxy/onboarding/generate-assets-json.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In that case, the assets.json should live alongside the ci.yml in the sdk/<Servi
Generated assets.json file contents
- AssetsRepo: "Azure/azure-sdk-assets" - This is the assets repository, aka where your recordings will live after this script runs.
- AssetsRepoPrefixPath: "<language>" - this is will be computed from repository it's being run in.
- AssetsRepoPrefixPath: "<language>" - this is will be computed from repository it's being run in.
- TagPrefix: "<language>/<ServiceDirectory>" or "<language>/<ServiceDirectory>/<library>" or deeper if things
are nested in such a manner. All tags created for this assets.json will start with this name.
- Tag: "" - Initially empty, as nothing has yet been pushed.
Expand Down Expand Up @@ -81,6 +81,7 @@ $LangRecordingDirs = @{"cpp" = "recordings";
. (Join-Path $PSScriptRoot "common-asset-functions.ps1")

Test-Exe-In-Path -ExeToLookFor $GitExe

$language = Get-Repo-Language

# If the initial push is being performed, ensure that test-proxy is
Expand All @@ -89,7 +90,7 @@ $language = Get-Repo-Language
if ($InitialPush) {
$proxyPresent = Test-Exe-In-Path -ExeToLookFor $TestProxyExe -ExitOnError $false

# try to fall back
# try to fall back
if (-not $proxyPresent) {
$StandaloneTestProxyExe = "Azure.Sdk.Tools.TestProxy"

Expand All @@ -107,6 +108,17 @@ if ($InitialPush) {
Write-Error "The user has selected option InitialPush to push their assets, neither $TestProxyExe nor standalone executable $StandaloneTestProxyExe are installed on this machine."
exit 1
}

# if we're pushing, we also need to confirm that the necessary git configuration items are set
$result = git config --get user.name
if ($LASTEXITCODE -ne 0 -or !$result){
Write-Error "The git config setting `"user.name`" is unset. Set it to your git user name via 'git config --global user.name `"<setting>`'"
}

$result = git config --get user.email
if ($LASTEXITCODE -ne 0 -or !$result){
Write-Error "The git config setting `"user.email`" is unset. Set it to your git email via 'git config --global user.email `"<setting>`'"
}
}

if ($TestProxyExe -eq "test-proxy" -or $TestProxyExe.StartsWith("Azure.Sdk.Tools.TestProxy")) {
Expand Down

0 comments on commit 63a5f57

Please sign in to comment.