fregante / ghat

🛕 Reuse GitHub Actions workflows across repositories
https://npm.im/ghat
MIT License
264 stars 9 forks source link

Error: could not find commit hash for master #16

Closed daniellockyer closed 3 years ago

daniellockyer commented 3 years ago

degit defaults to master for cloning, but new GitHub repositories use main as the default branch. I just set up a new repo and tried to use ghat, but get the following error:

(node:95712) UnhandledPromiseRejectionWarning: Error: could not find commit hash for master
    at Degit._cloneWithTar (/home/neo/ghat/node_modules/degit/dist/index-26d8486e.js:15037:10)
    at async Degit.clone (/home/neo/ghat/node_modules/degit/dist/index-26d8486e.js:14878:4)
    at async ghat (/home/neo/ghat/lib.js:63:2)
    at async /home/neo/ghat/bin.js:32:4

I could change the default branch of my repo, but I was wondering if you had a better solution?

Reproduction

  1. Set up a new GitHub repo for templates
  2. Try and use ghat elsewhere with this template repo
  3. See the following error: Error: could not find commit hash for master

ghat version: v0.11.1

HugoDF commented 3 years ago

Looks like it's an upstream error from https://github.com/Rich-Harris/degit/issues/207#issuecomment-708409213

workaround is to do username/repo#main

Edit: that issue + some PRs to fix it look stale, maybe this is something that should be handled in this project

fregante commented 3 years ago

Thanks for trying and reporting! Being a previous Rollup collaborator (ish), I had pinged @Rich-Harris to possibly becoming a maintainer of degit but I haven't received an answer yet.

Handling it here probably means doing a preflight request to GitHub to find the branch

fregante commented 3 years ago

This was a major oversight on my part since I expect ghat users to create new repos, which would now likely use main

I patched the latest version until a proper default branch detection is implemented, hopefully in degit.

daniellockyer commented 3 years ago

@fregante Perfect, thanks! 🙏🏻