Skip to content

Conversation

ahal
Copy link
Collaborator

@ahal ahal commented Oct 9, 2025

No description provided.

@ahal ahal self-assigned this Oct 9, 2025
@ahal ahal requested a review from a team as a code owner October 9, 2025 20:43
@ahal ahal requested a review from bhearsum October 9, 2025 20:43
@ahal ahal marked this pull request as draft October 9, 2025 20:43
This function works with anything committish, update the argument name
to reflect that (while we're breaking backwards compat anyway).
@ahal ahal force-pushed the ahal/push-kmlzomtxmptr branch from 2e8a2c1 to 0a5acfb Compare October 9, 2025 20:56
BREAKING CHANGE: the base_ref and base_rev parameters will now match
what was passed into the Decision task exactly. This means `base_ref`
will not get reset to the repo's default branch, and `base_rev` will no
longer be reset to the merge base.

### Why we were previously post-processing these parameters

Github push and pull_request events almost never contain the base ref,
and often don't contain the base rev. For base ref, it only ever seems
to be present when pushing a new branch. For base rev it is missing in
the following cases:

1. All pull_request events. The value we pass in is actually the
   revision that the base ref happens to be pointing at when the event
   is fired.
2. Force pushes. The value we pass in is actually the old unreachable
   head rev that used to be on the branch

Really, we only ever get a proper base rev when doing normal
fast-forward pushes.

The reason we need a base rev in the first place, is to compute the
files changed. So let's say there's a PR with the following graph:

    A -> B -> C -> D (main)
         \
          E -> F (PR)


Based on the Github event, `D` is being passed in as `base_rev` and `F`
is being passed in as `head_rev`. The post-processing was essentially
running `git merge-base` to find `B`, so that we could then use `git
log` to find all files touched between `B..F`.

### Why the post-processing isn't actually necessary

It turns out that `git log D..F` already does the right thing! It means,
show me all commits reachable from `F`, but not reachable from `D`,
which is exactly what we want. Only files changed in `E` and `F` will be
included. So there's no benefit of using `merge-base` for the purposes
of finding changed files.

As far as the `base_ref` post-processing goes, all we were doing was
setting it to `repo.default_branch` if it doesn't exist (which is almost
always for pushes). While this likely works in most cases, we don't
actually have any idea what the real `base_ref` is, so it's not correct
to be doing this.

Since we don't even need `base_ref` to determine files changed, I think
it's fine to leave it as `None` in the event it wasn't passed in.

### Risks with this patch

While removing this should be fine for the purposes of determining
changed files, there might be other use cases that projects are using
the `merge-base` for. Such projects may need to determine the merge-base
on their own, therefore this patch is backwards incompatible.

### Future improvements

I think we should consider removing or renaming the `base_ref` and
`base_rev` parameters. As outlined, they are misleading (at least with
Github based repos) and don't actually represent the "base revision".

But for now, I'll save that particular change for another day.
@ahal ahal force-pushed the ahal/push-kmlzomtxmptr branch from 0a5acfb to 6cb4197 Compare October 10, 2025 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants