MarceloPrado / has-changed-path

GitHub Action that saves time and money in monorepo environments
MIT License
225 stars 33 forks source link

fatal: bad revision 'HEAD~1' #18

Closed tekumara closed 3 years ago

tekumara commented 3 years ago

My builds are failing to detect that the file has changed:

Run marceloprado/has-changed-path@v1
  with:
    paths: asu/__init__.py
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.7.10/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.10/x64/lib
/usr/bin/git diff --quiet HEAD~1 HEAD -- asu/__init__.py
fatal: bad revision 'HEAD~1'
Code in the following paths hasn't changed: asu/__init__.py
tekumara commented 3 years ago

Looks like is because actions/checkout@v2 fetches with depth=1:

Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +14bca51985e1e2426f26692f92c598c026d68a2c:refs/remotes/origin/main 
tekumara commented 3 years ago

To fix, set fetch-depth like so:

    - uses: actions/checkout@v2
      with:
        # so marceloprado/has-changed-path@v1 can detect changes
        fetch-depth: 2