Skip to content

Commit

Permalink
Update location of patch files
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Sep 18, 2020
1 parent 162268b commit d7a29f5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ steps:
echo "RepoName = $repName"
displayName: Check for changes
condition: and(succeeded(), eq(variables['HasChanges'], ''))
workingDirectory: ${{ parameters.WorkingDirectory }}
ignoreLASTEXITCODE: true

Expand Down
13 changes: 13 additions & 0 deletions eng/pipelines/eng-common-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,25 @@ stages:
displayName: Sync ${{ parameters.DirectoryToSync }} Directory

steps:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- pwsh: |
$patchDir = "$(System.DefaultWorkingDirectory)/patchfiles"
$patchfiles = git format-patch $(system.pullRequest.sourceBranch)...$(system.pullRequest.targetBranch) ${{ parameters.DirectoryToSync }} -o $patchDir
if ($patchfiles)
{
echo "##vso[task.setvariable variable=PatchFilesLocation]$patchDir"
echo "##vso[task.setvariable variable=HasChanges]$true"
}
displayName: Create Patch Files from Changes in PR
workingDirectory: $(System.DefaultWorkingDirectory)
- template: ./templates/steps/sync-directory.yml
parameters:
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
CommitMessage: "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools repository for Tools PR $(System.PullRequest.PullRequestNumber)"
DirectoryToSync: ${{ parameters.DirectoryToSync }}
PRBranchName: "sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)"
BaseBranchName: $(system.pullRequest.targetBranch)
PRTitle: "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools for PR $(System.PullRequest.PullRequestNumber)"
PRBody: >
Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools for PR https://github.com/Azure/azure-sdk-tools/pull/$(System.PullRequest.PullRequestNumber)<br>
Expand Down
40 changes: 18 additions & 22 deletions eng/pipelines/templates/steps/sync-directory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,28 @@ steps:
displayName: Create PRData Artifact
- ${{ each repo in parameters.Repos }}:
- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
- pwsh: |
git clone --branch ${{ parameters.BaseBranchName }} https://github.com/azure/${{ repo }}
$repoPath = "${{ repo }}/${{ parameters.DirectoryToSync }}"
- pwsh: |
git clone --branch ${{ parameters.BaseBranchName }} https://github.com/azure/${{ repo }}
$repoPath = "${{ repo }}/${{ parameters.DirectoryToSync }}"
if ($PatchFilesLocation)
{
pushd ${{ repo }}
$results = Get-ChildItem $PatchFilesLocation | % { $git am $_.FullName }
if ($results.Count -ne (Get-ChildItem $PatchFilesLocation).Count)
{
Write-Output "Failed to apply patch files"
exit 1
}
}
else
{
if (!(Test-Path $repoPath)) { mkdir $repoPath }
Remove-Item -v -r $repoPath
Copy-Item -v -r $(Build.SourcesDirectory)/${{ parameters.DirectoryToSync }} $repoPath
Get-ChildItem -r $repoPath
displayName: Copy ${{ parameters.DirectoryToSync }} from azure-sdk-tools to ${{ repo }}
workingDirectory: $(System.DefaultWorkingDirectory)
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- pwsh: |
git clone --branch ${{ parameters.BaseBranchName }} https://github.com/azure/${{ repo }}
$repoPath = "${{ repo }}/${{ parameters.DirectoryToSync }}"
$patchDir = "${{ repo }}/patchfiles"
pushd $(Build.SourcesDirectory)
git format-patch ${{ parameters.BaseBranchName }}...upstream/master ${{ parameters.DirectoryToSync }} -o $patchDir
popd
pushd ${{ repo }}
Get-ChildItem $patchDir | % { git am $_.FullName }
git clean -xfd
displayName: Copy ${{ parameters.DirectoryToSync }} from azure-sdk-tools to ${{ repo }}
workingDirectory: $(System.DefaultWorkingDirectory)
}
displayName: Copy ${{ parameters.DirectoryToSync }} from azure-sdk-tools to ${{ repo }}
workingDirectory: $(System.DefaultWorkingDirectory)
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml
parameters:
Expand Down

0 comments on commit d7a29f5

Please sign in to comment.