Find the base branch of a Pull request

I use drone with github and like to run it on a PR base.
My CI needs to run a command per changed folder, for which usually I’d use something like

git diff basebranch…HEAD --name-only

I tried git diff $DRONE_BRANCH…HEAD, but this does not seem to work with drone.
Also while looking at git branch --list (-r), it seems like drone does not know about those branches.

How can I achieve something similar within drone (preferably using the default git plugin)? I’m only interested in changed names/folders.


1 Like

After digging around a bit, I found a solution using git diff FETCH_HEAD^1 FETCH_HEAD^2

I’ve found another way to solve the problem:

base_branch_short_name="$(echo "$DRONE_COMMIT_REFSPEC" | sed -e 's/^.*://')"
git fetch origin "$base_branch_short_name"
git diff "$DRONE_COMMIT_SHA".."$base_branch"