diff --git a/tools/ReleaseEngineering/ServicingPipeline.ps1 b/tools/ReleaseEngineering/ServicingPipeline.ps1 index 2adf3843a0..b9d2ba4c86 100644 --- a/tools/ReleaseEngineering/ServicingPipeline.ps1 +++ b/tools/ReleaseEngineering/ServicingPipeline.ps1 @@ -89,6 +89,20 @@ $Cards = Get-GithubProjectCard -ColumnId $ToPickColumn.id & git fetch --all 2>&1 | Out-Null +$Branch = & git rev-parse --abbrev-ref HEAD +$RemoteForCurrentBranch = & git config "branch.$Branch.remote" +$CommitsBehind = [int](& git rev-list --count "$RemoteForCurrentBranch/$Branch" "^$Branch") + +If ($LASTEXITCODE -Ne 0) { + Write-Error "Failed to determine branch divergence" + Exit 1 +} + +If ($CommitsBehind -Gt 0) { + Write-Error "Local branch $Branch is out of date with $RemoteForCurrentBranch; consider git pull" + Exit 1 +} + $Entries = @(& git log $SourceBranch --first-parent --grep "(#\($($Cards.Number -Join "\|")\))" "--pretty=format:%H%x1C%s" | ConvertFrom-CSV -Delimiter "`u{001C}" -Header CommitID,Subject)