Skip to content

Commit

Permalink
Do not checkout existing
Browse files Browse the repository at this point in the history
  • Loading branch information
sima-zhu committed Mar 15, 2021
1 parent 79cd92d commit 8703553
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
31 changes: 30 additions & 1 deletion eng/common/pipelines/templates/steps/docs-metadata-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,27 @@ steps:
WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo
ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }}
RemoteName: ${{ parameters.RemoteName }}
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml
condition: and(Failed(), eq('${{ parameters.OnboardingBranch }}',''))
parameters:
RepoName: ${{ parameters.TargetDocRepoName }}
RepoOwner: ${{ parameters.TargetDocRepoOwner }}
PRBranchName: ${{ parameters.PRBranchName }}
CommitMsg: "Update docs metadata and targeting for release of ${{ parameters.ArtifactName }}"
PRTitle: "Docs.MS Release Updates for ${{ parameters.ArtifactName }}"
BaseBranchName: ${{ parameters.SourceBranchName }}
WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo
ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }}
GHReviewersVariable: ${{ parameters.GHReviewersVariable }}
GHTeamReviewersVariable: ${{ parameters.GHTeamReviewersVariable }}
PRLabels: ${{ parameters.PRLabels }}
CloseAfterOpenForTesting: ${{ parameters.CloseAfterOpenForTesting }}

- ${{if ne( parameters['OnboardingBranch'], '')}}:
- pwsh: |
Push-Location ${{ parameters.WorkingDirectory }}/repo
git reset --hard HEAD
git remote rm azure-sdk-fork
git checkout ${{ parameters.OnboardingBranch}}
displayName: Reset Docs Repo, Checkout Onboarding Branch
ignoreLASTEXITCODE: false
Expand Down Expand Up @@ -128,3 +142,18 @@ steps:
WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo
ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }}
RemoteName: ${{ parameters.RemoteName }}
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml
condition: Failed()
parameters:
RepoName: ${{ parameters.TargetDocRepoName }}
RepoOwner: ${{ parameters.TargetDocRepoOwner }}
PRBranchName: ${{ parameters.PRBranchName }}
CommitMsg: "Update docs metadata and targeting for release of ${{ parameters.ArtifactName }}"
PRTitle: "Docs.MS Release Updates for ${{ parameters.ArtifactName }}"
BaseBranchName: ${{ parameters.SourceBranchName }}
WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo
ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }}
GHReviewersVariable: ${{ parameters.GHReviewersVariable }}
GHTeamReviewersVariable: ${{ parameters.GHTeamReviewersVariable }}
PRLabels: ${{ parameters.PRLabels }}
CloseAfterOpenForTesting: ${{ parameters.CloseAfterOpenForTesting }}
9 changes: 7 additions & 2 deletions eng/common/scripts/git-branch-push.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ if ($LASTEXITCODE -ne 0)
exit $LASTEXITCODE
}

Write-Host "git checkout -b $PRBranchName"
git checkout -b $PRBranchName
# Check if the branch has existed in remote.
$existed_in_remote = git ls-remote --heads $RemoteName $PRBranchName
if (!$existed_in_remote) {
Write-Host "git checkout -b $PRBranchName"
git checkout -b $PRBranchName
}

if ($LASTEXITCODE -ne 0)
{
Write-Error "Unable to create branch LASTEXITCODE=$($LASTEXITCODE), see command output above."
Expand Down

0 comments on commit 8703553

Please sign in to comment.