I'm trying to set up a pull request build that calculates the files changed in a pull request on a certain path.
I'm trying to do this so that I can exercise any new tests introduced in the PR by running them multiple times (to ensure they are not flakey).
I know that the BITBUCKET_PR_DESTINATION_BRANCH variable exists, but it seems like that does not allow me to do what I want, because the merge that pipelines does for a pull-request build is not always the tip of the destination branch.
If the merge commit that happens on that build produces a merge, I can get the commit SHA using:
git rev-list --parents -n 1 HEAD | cut -d " " -f 3
I use that to grab the files like this:
git diff --name-only HEAD $(git rev-list --parents -n 1 HEAD | cut -d " " -f 3) -- test/
However, if the pull-request branch is up to date with the destination branch, no merge commit is produced, and the above does not work.
Is there any way to get the commit SHA Bitbucket Pipelines uses in the Build setup?
Or another easy way to produce a list of the changed files of a certain path in that PR?
