preactjs / compressed-size-action

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

fix: Incorrect fetch for `baseRef` #109

Closed rschristian closed 2 months ago

rschristian commented 6 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. 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 v11 # fetch will succeed, but not affect the repo
git reset --hard v11 # will fail with the same error as shown above

git fetch -n origin v11:v11
git reset --hard v11 # will succeed
github-actions[bot] commented 6 months ago

Size Change: 0 B

Total Size: 75.6 kB

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

compressed-size-action