File: set-default-branch.yml

package info (click to toggle)
golang-github-azure-azure-sdk-for-go 68.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 556,256 kB
  • sloc: javascript: 196; sh: 96; makefile: 7
file content (16 lines) | stat: -rw-r--r-- 755 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
parameters:
  WorkingDirectory: '$(System.DefaultWorkingDirectory)'
  RemoteRepo: 'origin'
  DefaultBranchVariableName: DefaultBranch
steps:
- pwsh: |
    $setDefaultBranch = (git remote show ${{ parameters.RemoteRepo }} | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1'
    if ($LASTEXITCODE -ne 0) {
      Write-Host "Not able to fetch the default branch from git command. Set to main."
      $setDefaultBranch = 'main'
    }
    Write-Host "Setting ${{ parameters.DefaultBranchVariableName }}=$setDefaultBranch"
    Write-Host "##vso[task.setvariable variable=${{ parameters.DefaultBranchVariableName }}]$setDefaultBranch"
  displayName: "Setup Default Branch"
  workingDirectory: ${{ parameters.workingDirectory }}
  ignoreLASTEXITCODE: true