bahmutov / pre-git

Automatically install pre-commit / pre-push hooks in your git repo
168 stars 22 forks source link

post-checkout with no config present #111

Closed AVVS closed 7 years ago

AVVS commented 7 years ago

pre-git finds package.json, but it has no "config": { "pre-git" } section as master branch doesn't have pre-git installed yet, nor the config for it.

This causes post-checkout to exit with an error, which causes problems with CI (in my case semaphore)

It would be grand that in case where package.json is found, but no configuration is in there, it would fall back to noop

If you have any other ideas on how to avoid the issue - please let me know, thanks!

vitaly: ~/projects/cappasity-core  (ms-users-v7) $ DEBUG=pre-git git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
  pre-git git prefix env  +0ms
  pre-git running post-checkout +3ms
  pre-git git root folder /Users/vitaly/projects/cappasity-core +14ms
  pre-git set dir to /Users/vitaly/projects/cappasity-core for cwd /Users/vitaly/projects/cappasity-core and git prefix  +1ms
  pre-git found package file /Users/vitaly/projects/cappasity-core/package.json +0ms
  pre-git could not find package in the git root folder +1ms
  pre-git running post-checkout in /Users/vitaly/projects/cappasity-core +2ms
  pre-git running post-checkout at root /Users/vitaly/projects/cappasity-core +0ms
  pre-git cli arguments [ '/Users/vitaly/.nvm/versions/node/v8.1.3/bin/node',
  '/Users/vitaly/projects/cappasity-core/node_modules/pre-git/bin/post-checkout.js',
  '9c13049b9c381c40335e22e59ccb43e0c9eacd1e',
  'bfd85dd23d4a5829c9115f945ac73903ed0e95e2',
  '1' ] +1ms
  pre-git cwd /Users/vitaly/projects/cappasity-core +2ms
  pre-git set dir to /Users/vitaly/projects/cappasity-core for cwd /Users/vitaly/projects/cappasity-core and git prefix  +0ms
  pre-git found package file /Users/vitaly/projects/cappasity-core/package.json +0ms

post-checkout You've failed to pass all the hooks.
post-checkout
post-checkout An Error was thrown from command
Error: Could not find package.json starting from /Users/vitaly/projects/cappasity-core
post-checkout
post-checkout    at verifyValidDirectory (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:35:11)
post-checkout    at findPackage (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:58:3)
post-checkout    at findPackage (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:65:10)
post-checkout    at findPackage (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:65:10)
post-checkout    at findPackage (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:65:10)
post-checkout    at findPackage (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:65:10)
post-checkout    at getPackage (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:69:18)
post-checkout    at getTasks (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:196:13)
post-checkout    at runTasksForLabel (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:306:17)
post-checkout    at runAtRoot (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:333:10)
post-checkout    at getProjRoot.tap.then (/Users/vitaly/projects/cappasity-core/node_modules/pre-git/src/pre-git.js:345:21)
post-checkout    at tryCatcher (/Users/vitaly/projects/cappasity-core/node_modules/bluebird/js/release/util.js:16:23)
post-checkout    at Promise._settlePromiseFromHandler (/Users/vitaly/projects/cappasity-core/node_modules/bluebird/js/release/promise.js:512:31)
post-checkout    at Promise._settlePromise (/Users/vitaly/projects/cappasity-core/node_modules/bluebird/js/release/promise.js:569:18)
post-checkout    at Promise._settlePromise0 (/Users/vitaly/projects/cappasity-core/node_modules/bluebird/js/release/promise.js:614:10)
post-checkout    at Promise._settlePromises (/Users/vitaly/projects/cappasity-core/node_modules/bluebird/js/release/promise.js:693:18)
post-checkout
post-checkout You can skip the git hook by running with -n (--no-verify)
post-checkout
post-checkout But this is not advised as your tests are obviously failing.
bahmutov commented 7 years ago

Version 3.15.2 has been published to NPM. The full release note can be found at pre-git/releases/tag/v3.15.2.

Tip: safely upgrade dependency pre-git in your project using next-update

AVVS commented 7 years ago

Thanks!

On Aug 1, 2017, at 1:30 PM, Gleb Bahmutov notifications@github.com wrote:

Version 3.15.2 has been published to NPM. The full release note can be found at pre-git/releases/tag/v3.15.2 https://github.com/bahmutov/pre-git/releases/tag/v3.15.2.

Tip: safely upgrade dependency pre-git in your project using next-update https://github.com/bahmutov/next-update — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bahmutov/pre-git/issues/111#issuecomment-319487525, or mute the thread https://github.com/notifications/unsubscribe-auth/ABol0SgHnmQegMRR_FX3ae-a9OhvYOxiks5sT4r8gaJpZM4OqE9V.