yarnhook icon indicating copy to clipboard operation
yarnhook copied to clipboard

git error when running yarnhook

Open the21st opened this issue 4 years ago • 1 comments

I cloned a project that uses yarnhook, changed a file, and then ran git checkout on that file. yarnhook got triggered, but it failed with this output:

<path_to_project>/node_modules/.bin/yarnhook
<path_to_project>/node_modules/yarnhook/node_modules/execa/index.js:303

                throw (result.error || new Error(result.stderr === '' ? result.stdout : result.stderr));
                ^
Error: fatal: Log for 'HEAD' only has 1 entries.
    at Function.module.exports.sync (<path_to_project>/node_modules/yarnhook/node_modules/execa/index.js:303:26)
    at Object.<anonymous> (<path_to_project>/node_modules/yarnhook/index.js:58:38)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
error Command failed with exit code 1.

Tried googling but found nothing. Any advice?

the21st avatar May 21 '20 11:05 the21st

Hi, thanks for reporting this issue. I'm working again on this project and would like to solve your problem.

The problem seems to be that your use of checkout is not a branch-changing one but yarnhook gets triggered anyway. Since theres's no git hook solely for pulls and branch changes we try to react to this with 3 different git hooks. I'll work a bit more on detecting branch changes and nothing else.

This probably wouldn't be an issue if you changed a branch at least once, in which case reflog for HEAD would have at least two entries. Thanks for catching an edge case.

I'll either rename this issue or close this one to create a blanket issue for the general problem.

frontsideair avatar Oct 11 '20 10:10 frontsideair