We want to list the files changed in a push, for code reactions.
The before field on a push is "where did this ref last point?" which is different from the contents of the push.
The contents of the push are determined by the list of commits in the push. We need to take the earliest commit in that list (which seems to be, the last one) and then get its parent, and then compare the tip of the push (after or the first commit in the list, same one) to that.
This will make both new branches and force-pushes find the correct list of changed files.
Also, we should probably never use before. It doesn't mean what we think it does, except maybe for pushes to the default branch when force-push is disallowed.
We want to list the files changed in a push, for code reactions.
The
before
field on a push is "where did this ref last point?" which is different from the contents of the push.The contents of the push are determined by the list of commits in the push. We need to take the earliest commit in that list (which seems to be, the last one) and then get its parent, and then compare the tip of the push (
after
or the first commit in the list, same one) to that.This will make both new branches and force-pushes find the correct list of changed files.
Also, we should probably never use
before
. It doesn't mean what we think it does, except maybe for pushes to the default branch when force-push is disallowed.