Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 1558 (#18178)
Browse files Browse the repository at this point in the history
* Set default branch to master if not set from git

* Added log messages

* Silent the failure if not able fetch default branch from git

* Update git-push-changes.yml

Co-authored-by: Sima Zhu <sizhu@microsoft.com>
Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 20, 2021
1 parent 839229a commit f746a2a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion eng/common/pipelines/templates/steps/set-default-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ parameters:
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 master."
$setDefaultBranch = 'master'
}
Write-Host "Setting DefaultBranch=$setDefaultBranch"
echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch"
Write-Host "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch"
displayName: "Setup Default Branch"
workingDirectory: ${{ parameters.workingDirectory }}
ignoreLASTEXITCODE: true

0 comments on commit f746a2a

Please sign in to comment.