update the migration script entrypoint to catch git config errors before the push happens (#5853)

Co-authored-by: Scott Beddall <scbedd@microsoft.com>
This commit is contained in:
Azure SDK Bot 2024-07-30 12:49:46 -07:00 committed by GitHub
parent 6960ad1247
commit ce0e7ced1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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.
@ -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
@ -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"
@ -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")) {