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

Error when generated changelog with breaking changes #1

Closed
shaffe-fr opened this issue Feb 9, 2021 · 2 comments
Closed

Error when generated changelog with breaking changes #1

shaffe-fr opened this issue Feb 9, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@shaffe-fr
Copy link
Contributor

Hi,
First of all thanks for your package, I'm glad to see a PHP based system to manage changelog and semver.

After struggling a bit to detect breaking change, I ended up with the following commit message:

feat(user): add some breaking feature
BREAKING CHANGES: some breaking change

I dumped the $summary in Changelog.php:303, the breaking change is detected

array:3 [
  "feat" => 1
  "fix" => 0
  "breaking_changes" => 1
]

However a fatal error is triggered from Changelog::getMarkdownChanges when calling Configuration::getTypeLabel with the type breaking_changes.

Fatal error: Uncaught TypeError: Return value of ConventionalChangelog\Configura
tion::getTypeLabel() must be of the type string, null 

In the configuration, no types are set by default for breaking_changes.

Removing the following lines from Configuration::fromArray method fixes the issue as breaking preset are merged in types in the constructor:

    public function fromArray(array $array)
    {
-        if (empty($array)) {
-            return;
-        }
-
        $defaults = [
            'root' => null,

With this fix applied, the changelog is generated with the breaking change twice. I guess it's the intended behaviour.

### ⚠ BREAKING CHANGES


##### User

* Some breaking change ([041fbe]()

### Features

##### User

* Add some breaking feature ([041fbe]()

I can PR that change if you want.

Thanks

@marcocesarato
Copy link
Owner

Hi,
thanks for your support and the detailed issue.
It was probably some leftover code from the old configuration system, so thanks for reporting this issue.
About the feat + breaking change duplicated yes it is intended, do you think it should only be one?

@marcocesarato marcocesarato added the bug Something isn't working label Feb 9, 2021
@shaffe-fr
Copy link
Contributor Author

shaffe-fr commented Feb 9, 2021

I think having it only in the BREAKING CHANGES section is enough.
However, as the description of the type (feat, perf...) can be different from the one on the BC, the current behaviour makes sense.

I would make BC description optionnal:

  • if BC has a description, keep current behaviour,
  • if BC has no description, only put changes in the BC section using the main description.

Not sure if the commit specs allows to have a BREAKING CHANGES without a description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants