Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(defaultValues): Added fallback for optional default values #99

Merged
merged 1 commit into from
May 4, 2020

Conversation

tomkaar
Copy link
Contributor

@tomkaar tomkaar commented Oct 3, 2019

We are using commitizen and after bumping it to version 4.0.3 that bumped the version of cz-conventional-changelog to version 3.0.1 we started getting the error message TypeError: Cannot read property 'defaultType' of undefined.

After some investigating we could track it to the default values introduced in PR #69.

This PR makes it so the default values are optional and safeguards so if no default values are present it does not crash.

We are using [commitizen](https://github.com/commitizen/cz-cli) and after bumping it to version 4.0.3 that bumped the version of [cz-conventional-changelog](https://github.com/commitizen/cz-conventional-changelog) to version 3.0.1 we started getting the error message .

After some investigating we could track it to the default values introduced in PR [commitizen#69](commitizen#69).

This PR makes it so the default values are optional and safeguards so if no default values are present it does not crash.
@michaellopez
Copy link

michaellopez commented Oct 4, 2019

Some more digging actually turn up 3398c02 as the culprit. Before that commit it was possible to send undefined as the default values to engine. That still seems to hold true, but the processing of options introduced in the mentioned commit does not take into account that configLoader.load() can return undefined which the previous iteration of the code didn't really care about.

So the question is whether configLoader.load() should be able to return undefined, is that a proper case? I think it is, because documentation does not state that adapters are required, so a config shouldn't be required either.

@gabemeola
Copy link

gabemeola commented May 4, 2020

Can we get this merged?
In our use case, a we are passing a config to to bootstrap which doesn't seem to get to this adapter. https://github.com/commitizen/cz-cli/blob/master/src/cli/git-cz.js#L12

Sometimes a package.json file isn't present.

@michaellopez
Copy link

We'd be happy to do anything to move this along and get it in. Glad someone else also needs this 😊

@jimthedev jimthedev merged commit 2aae317 into commitizen:master May 4, 2020
@commitizen-bot
Copy link

🎉 This PR is included in version 3.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to DawChihLiou/cz-conventional-changelog-with-jiraid-detection that referenced this pull request Sep 16, 2020
# 1.0.0 (2020-09-16)

### Bug Fixes

* **adapter:** Fix typo in etc. ([39182b8](39182b8))
* **build:** Add proper deps, force republish to make sure things are working ([922097b](922097b))
* **build:** Automatic releases!!! ✨ ([114f967](114f967))
* update longest to ^2 ([commitizen#88](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/88)) ([7234529](7234529))
* **commit:** Remove es6 string syntax (backticks) ([7f922f2](7f922f2))
* **commit:** remove parentheses when there is no scope present ([55f72b9](55f72b9))
* **config-loader:** captured the direct dependency on commitizen for the use of the config loader ([commitizen#90](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/90)) ([4b23bbc](4b23bbc)), closes [commitizen#89](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/89)
* **defaultValues:** Added fallback for optional default values ([commitizen#99](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/99)) ([2aae317](2aae317))
* **package.json:** install missing dependency ([4287211](4287211))
* **package.json:** update package name ([2985968](2985968))
* **prompter:** resolve issue with new inquirer api ([commitizen#18](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/18)) ([807b4e5](807b4e5))
* Correct typo in JSON ([58df4d1](58df4d1))
* **release:** attempt to fix release ([c167fd8](c167fd8))
* **release.config.js:** attempt to fix semantic release ([e362f9a](e362f9a))
* **require:** get rid of relative path to the word-wrap ([e98818a](e98818a)), closes [commitizen#4](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/4)
* **wrapping:** Fix fields to wrap instead of truncate at 100 characters ([c7b7e11](c7b7e11)), closes [commitizen/cz-cli#4](commitizen/cz-cli#4)
* remove pre-node 10 support ([commitizen#86](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/86)) ([76588ad](76588ad))
* Update conventional-commit-types to the latest version 🚀 ([commitizen#105](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/105)) ([5a371c1](5a371c1))
* Wrap updateTypes in packageRules ([0f6dfbf](0f6dfbf))

### Features

* **adapter:** Create initial commit. ([4e8da01](4e8da01))
* **adapter:** refactor to engine, default to conventional commit types ([c8452d1](c8452d1)), closes [commitizen#29](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/29)
* **adapter:** Split breaking changes into separate question ([commitizen#44](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/44)) ([2d78e1d](2d78e1d)), closes [commitizen#17](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/17)
* add default values to options ([commitizen#69](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/69)) ([65d6a9f](65d6a9f))
* implement configuration through package.json ([commitizen#75](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/75)) ([3398c02](3398c02))
* **engine:** add support for disableScopeLowerCase ([commitizen#96](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/96)) ([e7bd546](e7bd546))
* **engine:** add support for disableSubjectLowerCase ([df66875](df66875))
* **engine.js:** add jira step ([b6c6bfb](b6c6bfb))
* **prompt:** add confirmation fields + edit for clarity ([commitizen#58](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/58)) ([d40ac2c](d40ac2c)), closes [commitizen#52](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/52)
* **types:** add suport for custom types ([commitizen#104](https://github.com/DawChihLiou/cz-conventional-changelog-with-jiraid-detection/issues/104)) ([aae2548](aae2548))

### BREAKING CHANGES

* Node 10 is LTS so please upgrade to it.
* **adapter:** Breaking changes now automatically include the "BREAKING CHANGE: " prefix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants