paths-filter icon indicating copy to clipboard operation
paths-filter copied to clipboard

Changed files with git commands detects too many files

Open mirpedrol opened this issue 2 years ago • 0 comments

Hello!

We are using this GitHub Action with the modification in https://github.com/dorny/paths-filter/pull/133 to avoid reaching the API Rate limit. Using git commands, the action paths filter uses the command git rev-parse HEAD to obtain the last commit. In PR events, this is the pre merge commit id. Because of that, we see too many files changed, not only the ones in the current PR.

One solution is to use git rev-parse HEAD^2 instead, in order to obtain the real last commit from the PR branch. In the GitHub workflow yaml file, the following must also be added:

- uses: actions/checkout@v4
        with:
          fetch-depth: 2 # To retrieve the preceding commit.

I'm happy to open a PR to address this if you think it's the right way to go :)

mirpedrol avatar Oct 25 '23 10:10 mirpedrol