get-changed-files icon indicating copy to clipboard operation
get-changed-files copied to clipboard

Error: "Not Found" when pushing a new branch

Open seahindeniz opened this issue 4 years ago • 2 comments

Hi @Ana06, do you think it's possible to have a solution for this issue? https://github.com/jitterbit/get-changed-files/issues/10

It also appears on this fork as well

seahindeniz avatar Oct 25 '21 13:10 seahindeniz

The error is coming from the github api as the commit id is 0000000000000000000000000000000000000000. It may be possible to use the branch name in this case. I would need to try it out, but not sure when I'll have time.

There is a workaround here: https://github.com/trilom/file-changes-action/issues/116#issuecomment-790007782

Ana06 avatar Oct 27 '21 20:10 Ana06

I also got into this and was so confused because it was working on one project but not another one and I found out how to handle it:

It seems the source code is here https://github.com/jitterbit/get-changed-files/blob/master/src/main.ts#L28-L36 The code handles 2 different events from GitHub Actions push & pull_request.

  • When creating a new branch for a PR, push will be triggered immediately before the PR gets created
  • The GitHub API / GitHub context base commit is then 0000000000000000000000000000000000000000
  • The get-changed-files action needs to have a non 0/empty base commit to be able to diff
  • Defining both push (and specify the branches) and pull_request solves the problem Example
on:
  push:
    branches:
      # Push events our default branch
      - main
      # Push events to branches matching refs/heads/renovate/...
      - 'renovate/**'
  pull_request:
    paths-ignore:
      - '*.md'
      - 'renovate.json'

It makes sense to me as a new branch does not have a base / reference where it's from, it's "floating" around, it's when creating the PR that the base branch is selected.

A solution could be to always diff on the default branch, another could be to document this ⬆️

Jolg42 avatar Jan 13 '22 16:01 Jolg42