Skip to content

Commit

Permalink
Only run eng/common check when target branch is master
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu authored and azure-sdk committed Feb 18, 2021
1 parent ab0393d commit c2c86f8
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
steps:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- pwsh: |
$filesInCommonDir = git diff "origin/$(System.PullRequest.TargetBranch)" HEAD --name-only -- 'eng/common/*'
# Find the default branch of the repo
$defaultBranch = (git remote show origin | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1'
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-eng/common")) -and ($LASTEXITCODE -eq 0) -and ($filesInCommonDir.Count -gt 0))
Write-Host "Default Branch: ${defaultBranch}"
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-eng/common")) -and "$(System.PullRequest.TargetBranch)" -eq $defaultBranch)
{
Write-Host "##vso[task.LogIssue type=error;]Changes to files under 'eng/common' directory should not be made in this Repo`n${filesInCommonDir}"
Write-Host "##vso[task.LogIssue type=error;]Please follow workflow at https://github.com/Azure/azure-sdk-tools/blob/master/doc/common/common_engsys.md"
exit 1
$filesInCommonDir = git diff "origin/$(System.PullRequest.TargetBranch)" HEAD --name-only -- 'eng/common/*'
if (($LASTEXITCODE -eq 0) -and ($filesInCommonDir.Count -gt 0))
{
Write-Host "##vso[task.LogIssue type=error;]Changes to files under 'eng/common' directory should not be made in this Repo`n${filesInCommonDir}"
Write-Host "##vso[task.LogIssue type=error;]Please follow workflow at https://github.com/Azure/azure-sdk-tools/blob/master/doc/common/common_engsys.md"
exit 1
}
}
displayName: Prevent changes to eng/common outside of azure-sdk-tools repo
condition: and(succeeded(), ne(variables['Skip.EngCommonWorkflowEnforcer'], 'true'))

0 comments on commit c2c86f8

Please sign in to comment.