I want to get all the file contents that are included in a pull request. I tried the rest API endpoint https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20request%20commits/get%20pull%20request%20commits?view=azure-devops-rest-6.0 and this does get me all the commits that are in the pull request. I then was able to retrieve the file contents for these commits. However when there are multiple commits and the same file was changed, I end up getting the old file contents that is no longer valid in the latest pull request iteration.
Example:
- File A changed in commit 1. New File B was also added in commit 1.
- File A changed again in commit 2.
- Pull request created.
In the example above, I want to get the file content from commit 2 for File A plus file content of File B from commit 1. I might be able to calculate this by calling https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20request%20iteration%20changes/get?view=azure-devops-rest-6.0 but hoping there is a good way to get the final view of the pull request, and it's file contents.
My goal is to run custom validations against the files in the pull request and block completing the pull request. To run the validations, I need to get the file contents.