Include disambiguation for branch name using EmitterPackagePath (#6778)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
This commit is contained in:
Azure SDK Bot 2025-10-10 10:25:59 -07:00 committed by GitHub
parent e19518ea0a
commit 6ad8fa48b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -137,13 +137,28 @@ extends:
$sourceBranch = '$(Build.SourceBranch)'
$buildReason = '$(Build.Reason)'
$buildNumber = '$(Build.BuildNumber)'
$emitterPackagePath = '${{ parameters.EmitterPackagePath }}'
# Create emitter identifier from package path for disambiguation
$emitterIdentifier = ""
if (-not [string]::IsNullOrWhiteSpace($emitterPackagePath)) {
# Extract filename without extension and make it safe for branch names
$emitterIdentifier = [System.IO.Path]::GetFileNameWithoutExtension($emitterPackagePath)
# Replace any characters that aren't alphanumeric, hyphens, or underscores
$emitterIdentifier = $emitterIdentifier -replace '[^a-zA-Z0-9\-_]', '-'
# Remove any leading/trailing hyphens and convert to lowercase
$emitterIdentifier = $emitterIdentifier.Trim('-').ToLower()
if (-not [string]::IsNullOrWhiteSpace($emitterIdentifier)) {
$emitterIdentifier = "-$emitterIdentifier"
}
}
if ($buildReason -eq 'Schedule') {
$branchName = 'validate-typespec-scheduled'
$branchName = "validate-typespec-scheduled$emitterIdentifier"
} elseif ($sourceBranch -match "^refs/pull/(\d+)/(head|merge)$") {
$branchName = "validate-typespec-pr-$($Matches[1])"
$branchName = "validate-typespec-pr-$($Matches[1])$emitterIdentifier"
} else {
$branchName = "validate-typespec-$buildNumber"
$branchName = "validate-typespec-$buildNumber$emitterIdentifier"
}
Write-Host "Setting variable 'branchName' to '$branchName'"