preactjs / compressed-size-action

GitHub Action that adds compressed size changes to your PRs.
https://github.com/marketplace/actions/compressed-size-action
MIT License
603 stars 84 forks source link

fix: Incorrect fetch for `baseRef` #109

Open rschristian opened 4 months ago

rschristian commented 4 months ago
 /usr/bin/git fetch -n origin main
  From https://github.com/preactjs/preact
   * branch              main       -> FETCH_HEAD
   * [new branch]        main       -> origin/main
  successfully fetched base.ref
  checking out and building base commit
  /usr/bin/git reset --hard main
  fatal: ambiguous argument 'main': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

As the repo is a shallow clone, fetches will only update the remote branch tracking the currently cloned branch, i.e., git fetch <another branch> won't have any effect (to my understanding). Providing a local branch to track the remote from will fix this, however.

Simple demonstration of the issue:

git clone git@github.com:preactjs/preact.git --depth=1
cd preact
git fetch -n origin disable-rendering-on-unmount # fetch will succeed, but not affect the repo
git reset --hard disable-rendering-on-unmount # will fail with the same error as shown above

git fetch -n origin disable-rendering-on-unmount:disable-rendering-on-unmount
git reset --hard disable-rendering-on-unmount # will succeed
github-actions[bot] commented 4 months ago

Size Change: 0 B

Total Size: 75.6 kB

ℹ️ View Unchanged | Filename | Size | | :--- | :---: | | `index.js` | 75.6 kB |

compressed-size-action