semantic-release / commit-analyzer

:bulb: semantic-release plugin to analyze commits with conventional-changelog
MIT License
363 stars 73 forks source link

Commit analyzer does not handle commits with empty messages #147

Closed duffsterlp closed 4 years ago

duffsterlp commented 4 years ago

Current behavior

When commit-analyzer analyzes a commit that had been created using git commit --allow-empty-message --allow-empty, it encounters the following error:

[1:20:47 PM] [semantic-release] › ✖  An error occurred while running semantic-release: { TypeError: Expected a raw commit
    at parser (/usr/lib/node_modules/semantic-release/node_modules/conventional-commits-parser/lib/parser.js:79:11)
    at sync (/usr/lib/node_modules/semantic-release/node_modules/conventional-commits-parser/index.js:96:10)
    at commits.map (/usr/lib/node_modules/semantic-release/node_modules/@semantic-release/commit-analyzer/index.js:33:95)
    at Array.map (<anonymous>)
    at analyzeCommits (/usr/lib/node_modules/semantic-release/node_modules/@semantic-release/commit-analyzer/index.js:33:13)
    at process.internalTickCallback (internal/process/next_tick.js:77:7) pluginName: '@semantic-release/commit-analyzer' }
{ TypeError: Expected a raw commit
    at parser (/usr/lib/node_modules/semantic-release/node_modules/conventional-commits-parser/lib/parser.js:79:11)
    at sync (/usr/lib/node_modules/semantic-release/node_modules/conventional-commits-parser/index.js:96:10)
    at commits.map (/usr/lib/node_modules/semantic-release/node_modules/@semantic-release/commit-analyzer/index.js:33:95)
    at Array.map (<anonymous>)
    at analyzeCommits (/usr/lib/node_modules/semantic-release/node_modules/@semantic-release/commit-analyzer/index.js:33:13)
    at process.internalTickCallback (internal/process/next_tick.js:77:7) pluginName: '@semantic-release/commit-analyzer' }

Expected behavior

The tool should skip empty commits and handle commits created with empty messages. The use case for this is to make a dummy commit in order to kick off a CI/CD pipeline.

Environment

pvdlg commented 4 years ago

I fixed that in #148. However committing empty commit messages seems to be a very bad practice. It will live you with commits that pollute your commit history and someone going through the history of your repo will have a hard time figuring out what those commits are. In addition they can't be trusted to not contain code changes as anyone can make a commit with code changes and an empty message.

Most CI offer feature to manually launch a build on a given branch. If your CI doesn't offer such feature I would strongly recommend switching to a better one. If you can't then instead of empty commits I would recommend to use commits with an actual message explaining what's going on.

duffsterlp commented 4 years ago

Thanks @pvdlg for the fix and for the information. I'm not familiar with the release process of these tools. Is that going to be rolled into the next release of commit-analyzer in the near future?

semantic-release-bot commented 4 years ago

:tada: This issue has been resolved in version 6.3.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

semantic-release-bot commented 4 years ago

:tada: This issue has been resolved in version 7.0.0-beta.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: