diff --git a/eng/pipelines/eng-common-sync.yml b/eng/pipelines/eng-common-sync.yml index 18e7fe4c7886..870b3411d197 100644 --- a/eng/pipelines/eng-common-sync.yml +++ b/eng/pipelines/eng-common-sync.yml @@ -31,19 +31,6 @@ stages: steps: - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - - task: PowerShell@2 - displayName: 'Get alias of the Tools PR Creator' - inputs: - targetType: filePath - filePath: $(Build.SourcesDirectory)/eng/common/scripts/get-pr-creator.ps1 - arguments: > - -RepoOwner "Azure" - -RepoName "azure-sdk-tools" - -PullRequestNumber "$(System.PullRequest.PullRequestNumber)" - -VsoPRCreatorVariable "System.PullRequest.Creator" - -AuthToken "$(azuresdk-github-pat)" - pwsh: true - - pwsh: | Set-PsDebug -Trace 1 $patchDir = "$(Build.ArtifactStagingDirectory)/patchfiles" @@ -51,6 +38,7 @@ stages: if ($patchfiles -and ($LASTEXITCODE -eq 0)) { echo "##vso[task.setvariable variable=PatchFilesLocation]$patchDir" echo "Setting PatchFilesLocation" + ls $patchDir } else { Write-Host "Failed to Create PatchFiles from Pull Request [https://github.com/Azure/azure-sdk-tools/pull/$(System.PullRequest.PullRequestNumber)]" diff --git a/eng/pipelines/templates/steps/sync-directory.yml b/eng/pipelines/templates/steps/sync-directory.yml index c03725af368e..9345ecd792d6 100644 --- a/eng/pipelines/templates/steps/sync-directory.yml +++ b/eng/pipelines/templates/steps/sync-directory.yml @@ -24,19 +24,22 @@ steps: pushd ${{ repo }} $results = @() echo "##vso[task.setvariable variable=HasChanges]$false" - foreach ($file in (Get-ChildItem $(PatchFilesLocation))) + $shaBeforePatches = git rev-parse --short HEAD + Write-Host $shaBeforePatches + foreach ($file in (Get-ChildItem $(PatchFilesLocation)*.patch)) { - $results += git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" am $file.FullName - } - if (($results.Count -eq (Get-ChildItem $(PatchFilesLocation))) -and ($LASTEXITCODE -eq 0)) - { - echo "##vso[task.setvariable variable=HasChanges]$true" - } - else - { - Write-Output "Failed to properly apply patch files to [https://github.com/azure/${{ repo }}]" - echo "##vso[task.setvariable variable=HasChanges]$false" + Write-Host $file.FullName + git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" am -3 $file.FullName + if ($lastExitCode -ne 0) { + git am --show-current-patch=diff + Write-Error "##vso[task.LogIssue type=warning;]Failed to properly apply patch files to [https://github.com/azure/${{ repo }}]" + exit 1 + } } + $shaAfterPatches = git rev-parse --short HEAD + Write-Host $shaAfterPatches + $hasChanges = $shaBeforePatches -ne $shaAfterPatches + echo "##vso[task.setvariable variable=HasChanges]$hasChanges" } else {