Skip to content

Commit 86f68e3

Browse files
azure-sdkCopilotJoshLove-msft
authored
Include disambiguation for branch name using EmitterPackagePath (#43340)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JoshLove-msft <[email protected]>
1 parent 8d6be59 commit 86f68e3

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

eng/common/pipelines/templates/archetype-typespec-emitter.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,28 @@ extends:
137137
$sourceBranch = '$(Build.SourceBranch)'
138138
$buildReason = '$(Build.Reason)'
139139
$buildNumber = '$(Build.BuildNumber)'
140+
$emitterPackagePath = '${{ parameters.EmitterPackagePath }}'
141+
142+
# Create emitter identifier from package path for disambiguation
143+
$emitterIdentifier = ""
144+
if (-not [string]::IsNullOrWhiteSpace($emitterPackagePath)) {
145+
# Extract filename without extension and make it safe for branch names
146+
$emitterIdentifier = [System.IO.Path]::GetFileNameWithoutExtension($emitterPackagePath)
147+
# Replace any characters that aren't alphanumeric, hyphens, or underscores
148+
$emitterIdentifier = $emitterIdentifier -replace '[^a-zA-Z0-9\-_]', '-'
149+
# Remove any leading/trailing hyphens and convert to lowercase
150+
$emitterIdentifier = $emitterIdentifier.Trim('-').ToLower()
151+
if (-not [string]::IsNullOrWhiteSpace($emitterIdentifier)) {
152+
$emitterIdentifier = "-$emitterIdentifier"
153+
}
154+
}
140155
141156
if ($buildReason -eq 'Schedule') {
142-
$branchName = 'validate-typespec-scheduled'
157+
$branchName = "validate-typespec-scheduled$emitterIdentifier"
143158
} elseif ($sourceBranch -match "^refs/pull/(\d+)/(head|merge)$") {
144-
$branchName = "validate-typespec-pr-$($Matches[1])"
159+
$branchName = "validate-typespec-pr-$($Matches[1])$emitterIdentifier"
145160
} else {
146-
$branchName = "validate-typespec-$buildNumber"
161+
$branchName = "validate-typespec-$buildNumber$emitterIdentifier"
147162
}
148163
149164
Write-Host "Setting variable 'branchName' to '$branchName'"

0 commit comments

Comments
 (0)