fix the target branch checking (#3474)
This commit is contained in:
parent
835f156af9
commit
6f426df9f3
@ -8,11 +8,10 @@ steps:
|
||||
- pwsh: |
|
||||
# Find the default branch of the repo. The variable value sets in build step.
|
||||
Write-Host "Default Branch: $(DefaultBranch)"
|
||||
$targetBranch = "$(System.PullRequest.TargetBranch)" -replace "refs/heads/"
|
||||
|
||||
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-eng/common")) -and $targetBranch -eq "$(DefaultBranch)")
|
||||
if ((!"$(System.PullRequest.SourceBranch)".StartsWith("sync-eng/common")) -and "$(System.PullRequest.TargetBranch)" -match "^(refs/heads/)?$(DefaultBranch)$")
|
||||
{
|
||||
$filesInCommonDir = & "eng/common/scripts/get-changedfiles.ps1" -TargetCommittish $targetBranch -DiffPath 'eng/common/*'
|
||||
$filesInCommonDir = & "eng/common/scripts/get-changedfiles.ps1" -DiffPath '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}"
|
||||
|
||||
@ -10,7 +10,7 @@ function Get-ChangedFiles {
|
||||
[string]$DiffFilterType = "d"
|
||||
)
|
||||
# If ${env:SYSTEM_PULLREQUEST_TARGETBRANCH} is empty, then return empty.
|
||||
if ($TargetCommittish -eq "origin/") {
|
||||
if (!$TargetCommittish -or ($TargetCommittish -eq "origin/")) {
|
||||
Write-Host "There is no target branch passed in. "
|
||||
return ""
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user