Skip to content

Commit

Permalink
Use Unique Branch Names (microsoft#67)
Browse files Browse the repository at this point in the history
* Use Unique Branch Names

* Process Branch Names Safely
  • Loading branch information
Trenly committed Oct 13, 2021
1 parent f71c7a7 commit e93b2f2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Tools/YamlCreate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ Function Write-Locale-Manifests {

# Create the folder for the file if it doesn't exist
New-Item -ItemType 'Directory' -Force -Path $AppFolder | Out-Null
$LocaleManifestPath = $AppFolder + "\$PackageIdentifier" + '.locale.' + "$PackageLocale" + '.yaml'
$script:LocaleManifestPath = $AppFolder + "\$PackageIdentifier" + '.locale.' + "$PackageLocale" + '.yaml'

# Write the manifest to the file
$ScriptHeader + "$(GetDebugString)`n$yamlServer`n" > $LocaleManifestPath
Expand Down Expand Up @@ -2180,11 +2180,14 @@ if ($PromptSubmit -eq '0') {
git fetch upstream master --quiet
git switch -d upstream/master
if ($LASTEXITCODE -eq '0') {
$UniqueBranchID = $(Get-FileHash $script:LocaleManifestPath).Hash[0..6] -Join ""
$BranchName = "$PackageIdentifier-$BranchVersion-$UniqueBranchID"
#Git branch names cannot start with `.` cannot contain any of {`..`, `\`, `~`, `^`, `:`, ` `, `?`, `@{`, `[`}, and cannot end with {`/`, `.lock`, `.`}
$BranchName = $BranchName -replace '[\~,\^,\:,\\,\?,\@\{,\*,\[,\s]{1,}|[.lock|/|\.]*$|^\.{1,}|\.\.',""
git add -A
git commit -m "$CommitType`: $PackageIdentifier version $PackageVersion" --quiet

git switch -c "$PackageIdentifier-$PackageVersion" --quiet
git push --set-upstream origin "$PackageIdentifier-$PackageVersion" --quiet
git switch -c "$BranchName" --quiet
git push --set-upstream origin "$BranchName" --quiet

# If the user has the cli too
if (Get-Command 'gh.exe' -ErrorAction SilentlyContinue) {
Expand Down

0 comments on commit e93b2f2

Please sign in to comment.