Skip to content

Process all parent commits in a merge commit, not only the 1st one? #346

@dimikot

Description

@dimikot

Hi.

Can the action check not only the 1st parent of a merge commit for changed files, but ALL parents, searching for the one which has no changed files against, and for which the workflow passed?

Here is an illustration:

We use Merge button, and it produces merge commits (like m4). Each merge commit (m4 on the picture) has not one, but 2 parents: one on the main branch itself (m1) and another one on the feature branch (c3). We can see on the picture that the code in c3 will be identical to the code on m4, and since the workflow passes for c3, it can safely be skipped for m4 too.

In fact, the action behaves like this OFTEN, but sometimes, it still doesn't recognize the situation: instead of comparing the code between c3 and m4, it compares it between m1 and m4, which effectively disables skipping.

Here is likely where it is in the code:

iterSha = commit.parents?.length ? commit.parents[0]?.sha : null

I see that it only chooses the 1st parent in the list of parents. But for merge commits (like m4 on the picture above), there are 2 parents, and they BOTH are worth checking.

I think that GitHub API returns parents of a merge commit in an unpredictable order, so sometimes it guesses out the correct parent, and sometimes it does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions