conventional-changelog-archived-repos / validate-commit-msg

DEPRECATED. Use https://github.com/marionebl/commitlint instead. githook to validate commit messages are up to standard
http://conventionalcommits.org/
MIT License
556 stars 101 forks source link

Crashes with undefined input #9

Closed bahmutov closed 8 years ago

bahmutov commented 8 years ago

Sometimes if called without an actual message, crashes badly trying to get the first line. For example from pre-git use

$ ../../.git/hooks/commit-msg
using built-in validator validate-commit-msg
/example/node_modules/pre-git/node_modules/validate-commit-msg/index.js:108
      return buffer.toString().split('\n').shift();
                   ^
TypeError: Cannot read property 'toString' of undefined
    at firstLineFromBuffer (/example/node_modules/pre-git/node_modules/validate-commit-msg/index.js:108:20)
bahmutov commented 8 years ago

but this happens outside the validateMessage function, so not covered by unit tests

function firstLineFromBuffer(buffer) {
    return buffer && buffer.toString().split('\n').shift();
 }
kentcdodds commented 8 years ago

I need to give you an apology. For some reason, I want watching this repository so I want getting notifications about issues and pull requests. I am so incredibly sorry. Please forgive me. I really feel awful. I hope my unresponsiveness doesn't hinder you contributing more in the future.

As for your specific pull request, I'll give it a closer look soon.