GithubHelp home page GithubHelp logo

marcocesarato / php-conventional-changelog Goto Github PK

View Code? Open in Web Editor NEW
219.0 5.0 31.0 643 KB

A PHP tool built to generate a changelog from a project's commit messages and metadata following the conventionalcommits.org and automate versioning with semver.org.

License: GNU General Public License v3.0

PHP 98.98% Dockerfile 1.02%
php composer commits commit php-convetional-commit git history conventional-changelog changelog generation

php-conventional-changelog's Introduction

Hi there ๐Ÿ‘‹

I'm Marco Cesarato, a Italian Fullstack Software Engineer.

I'm a weird guy ๐Ÿ‘ฝ who likes making weird things with the technology.

I like to resolve problems, create smart user interfaces and imagine useful interaction, developing rich web experiences & good web and mobile applications. I care about creating high-quality, in terms of UI/UX ๐Ÿ”ญ and performance ๐Ÿš€, applications.

I know likely all the most popular programming languages ๐Ÿ˜†, but I'm ready to pick up new one ๐ŸŒฑ.

  • ๐Ÿ‘ถ Programming since: 2012
  • ๐Ÿ“š Interests: I'm always interested in learning
  • ๐Ÿ˜ Favorite Programming Language: probably are TypeScript and Python, because they can be well structured and is dynamic at the same time, don't need too much external libaries and its learning cost is very low, saving more valuable time
  • ๐ŸŽฎ Hobbies: I like to play to League of Legends and I think to be a decent player, peak elo Master ๐Ÿ˜ƒ

php-conventional-changelog's People

Contributors

aatumaykin avatar aprat84 avatar attiks avatar boumanb avatar brunob avatar christoxz avatar gitrequests avatar guanguans avatar imgbotapp avatar jaymeh avatar juckerf avatar kishieel avatar marcocesarato avatar mottihoresh avatar renovate[bot] avatar romm avatar sh4dow avatar shaffe-fr avatar theratg avatar william-suppo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

php-conventional-changelog's Issues

Un-conventional comit messages should be ignored

Hello @marcocesarato,

thank you for offer this library.

We try to implement your library to generate a changelog.
It looks like unknown messages are not ignored, for example: "Merge remote-tracking branch 'origin/staging' into staging"

Also, it would be nice, it there is no commit message for the changelog, there should be no new tag generated, right?

> conventional-changelog --commit

Warning: Undefined array key "type" in /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/src/Git/ConventionalCommit.php on line 81

Call Stack:
    0.0002     419200   1. {main}() /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/conventional-changelog:0
    0.0163    2564576   2. Symfony\Component\Console\Application->run($input = ???, $output = ???) /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/conventional-changelog:44
...
    0.0577    3306304   9. unserialize($data = 'O:44:"ConventionalChangelog\\Git\\ConventionalCommit":10:{s:6:"\000*\000raw";s:59:"Merge remote-tracking branch \'origin/staging\' into staging\n";s:10:"\000*\000subject";N;s:7:"\000*\000body";N;s:7:"\000*\000hash";s:40:"b8958273461aa1ad3fa9284531896bf1b2bf9b9b";s:13:"\000*\000authorDate";O:8:"DateTime":3:{s:4:"date";s:26:"2021-02-10 14:17:51.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+01:00";}s:13:"\000*\000authorName";s:15:"Joerg Schneider";s:14:"\000*\000authorEmail";s:28:', $options = [0 => 'ConventionalChangelog\\Git\\ConventionalCommit']) /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/src/Git/ConventionalCommit.php:115
...


Warning: Undefined array key "scope" in /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/src/Git/ConventionalCommit.php on line 82

Call Stack:
    0.0002     419200   1. {main}() /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/conventional-changelog:0
    0.0163    2564576   2. Symfony\Component\Console\Application->run($input = ???, $output = ???) /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/conventional-changelog:44
...
    0.0577    3306304   9. unserialize($data = 'O:44:"ConventionalChangelog\\Git\\ConventionalCommit":10:{s:6:"\000*\000raw";s:59:"Merge remote-tracking branch \'origin/staging\' into staging\n";s:10:"\000*\000subject";N;s:7:"\000*\000body";N;s:7:"\000*\000hash";s:40:"b8958273461aa1ad3fa9284531896bf1b2bf9b9b";s:13:"\000*\000authorDate";O:8:"DateTime":3:{s:4:"date";s:26:"2021-02-10 14:17:51.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+01:00";}s:13:"\000*\000authorName";s:15:"Joerg Schneider";s:14:"\000*\000authorEmail";s:28:"', $options = [0 => 'ConventionalChangelog\\Git\\ConventionalCommit']) /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/src/Git/ConventionalCommit.php:115
...

Warning: Undefined array key "description" in /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/src/Git/ConventionalCommit.php on line 84

Call Stack:
    0.0002     419200   1. {main}() /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/conventional-changelog:0
    0.0163    2564576   2. Symfony\Component\Console\Application->run($input = ???, $output = ???) /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/conventional-changelog:44
...
    0.0577    3306304   9. unserialize($data = 'O:44:"ConventionalChangelog\\Git\\ConventionalCommit":10:{s:6:"\000*\000raw";s:59:"Merge remote-tracking branch \'origin/staging\' into staging\n";s:10:"\000*\000subject";N;s:7:"\000*\000body";N;s:7:"\000*\000hash";s:40:"b8958273461aa1ad3fa9284531896bf1b2bf9b9b";s:13:"\000*\000authorDate";O:8:"DateTime":3:{s:4:"date";s:26:"2021-02-10 14:17:51.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+01:00";}s:13:"\000*\000authorName";s:15:"Joerg Schneider";s:14:"\000*\000authorEmail";s:28:"', $options = [0 => 'ConventionalChangelog\\Git\\ConventionalCommit']) /home/circleci/project/vendor/marcocesarato/php-conventional-changelog/src/Git/ConventionalCommit.php:115
...

We eagerly await new version ;-)

Error with First Release (PHP 8.0)

For reproduce the problem create new project

  1. composer require --dev marcocesarato/php-conventional-changelog
  2. git init and create first commit

Trying changelog with --first-release flag

php vendor/bin/conventional-changelog --first-release

PHP Warning:  Undefined variable $newVersion in /path_to_project/vendor/marcocesarato/php-conventional-changelog/src/Changelog.php on line 172
PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #1 must be of type array, bool given in /path_to_project/vendor/marcocesarato/php-conventional-changelog/src/Changelog.php:545
Stack trace:
#0 /path_to_project/vendor/marcocesarato/php-conventional-changelog/src/Changelog.php(545): array_merge()
#1 /path_to_project/vendor/marcocesarato/php-conventional-changelog/src/Changelog.php(572): ConventionalChangelog\Changelog->getCompiledString()
#2 /path_to_project/vendor/marcocesarato/php-conventional-changelog/src/Changelog.php(369): ConventionalChangelog\Changelog->getCompareUrl()
#3 /path_to_project/vendor/marcocesarato/php-conventional-changelog/src/DefaultCommand.php(112): ConventionalChangelog\Changelog->generate()
#4 /path_to_project/vendor/symfony/console/Command/Command.php(256): ConventionalChangelog\DefaultCommand->execute()
#5 /path_to_project/vendor/symfony/console/Application.php(971): Symfony\Component\Console\Command\Command->run()
#6 /path_to_project/vendor/symfony/console/Application.php(290): Symfony\Component\Console\Application->doRunCommand()
#7 /path_to_project/vendor/symfony/console/Application.php(166): Symfony\Component\Console\Application->doRun()
#8 /path_to_project/vendor/marcocesarato/php-conventional-changelog/conventional-changelog(33): Symfony\Component\Console\Application->run()
#9 {main}

Trying changelog with --commit flag

php vendor/bin/conventional-changelog --commit

PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #1 must be of type array, bool given in /path_to_project/vendor/marcocesarato/php-conventional-changelog/src/Changelog.php:545
Stack trace: ...

Trying changelog with no flags

php vendor/bin/conventional-changelog

PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #1 must be of type array, bool given in /path_to_project/vendor/marcocesarato/php-conventional-changelog/src/Changelog.php:545
Stack trace: ...

Trying changelog with --history flag

php vendor/bin/conventional-changelog --history

Summary
=======
                                                                                                         
 [OK] Changelog generated!                                                                                              
 
 > Changelog file: CHANGELOG.md

But changelog is empty (only Title and Description)

php -v

PHP 8.0.5 (cli) (built: May  3 2021 11:30:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.5, Copyright (c), by Zend Technologies

"marcocesarato/php-conventional-changelog": "1.10.3"

Can you check it?

git 1.8.3 has not "%aI" and "%cI" parametrs

It turns out that git version 1.8.3 has no "%aI" parameter for pretty format.

vardump

  ["hash"]=>
  string(40) "695c3ffa82e3ca893f8b98de3e9d6b52f8502ed7"
  ["authorDate"]=>
  string(3) "%aI"
  ["committerDate"]=>
  string(3) "%cI"

Error when generated changelog with breaking changes

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

fatal: ambiguous argument '0.0.0...HEAD': unknown revision or path not in the working tree.

Hey,

first off thank you for making and maintaining this!

When I run composer changelog I get the following output:

> conventional-changelog

conventional-changelog 1.17.0
=============================

Checking environment requirements
 โœ“ Commands executions enabled
 โœ“ Git detected correctly
 โœ“ Git version detected: 2.43.0
 โœ“ Valid git worktree directory: /path/to/grandeljay/modified-consistent-flags
 โœ“ Valid git remote repository url: https://github.com/grandeljay/modified-consistent-flags

Generating changelog

Summary
-------

 [OK] Changelog generated!

 > Changelog file: CHANGELOG.md
fatal: ambiguous argument '0.0.0...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Is it due to my tags not starting with a v? I am using some more external tools and one them requires my git tags to be just numbers and dots. I already have 10 tags set.

Any ideas?

Plans for PHP 8 Support?

Hey there, really digging this library! it fills a much needed gap, and it's nice to have a PHP solution for PHP projects. Anyways.. onto the issue; title pretty much says it all.

Grazie di esistere

Avevo un'azione GITHUB che svolgeva questo compito ad ogni rilascio ma improvvisamente ha smesso di funzionare. Che dire il vostro script funziona alla perfezione.

Vi scrivo giusto per invitarvi a modificare leggermente la documentazione.

Nei comandi indicate di utilizzare php ma in realtร  non occorre mica.

su Windows ad esempio:

vendor/bin/conventional-changelog.bat --commit

Stessa cosa per il comando linux che รจ uno script quindi perchรฉ avviarlo con PHP?

Anche il piccolo video che si vede potrebbe risultare fuorviante.

Saluti

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update mcr.microsoft.com/vscode/devcontainers/php docker tag to v1

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

composer
composer.json
  • php >=7.1.3
  • symfony/console ^4 || ^5 || ^6
  • friendsofphp/php-cs-fixer ^3.8
  • brainmaestro/composer-git-hooks ^2.8
  • phpunit/phpunit ^9.6
  • php-mock/php-mock ^2.3
  • php-mock/php-mock-phpunit ^2.6
dockerfile
.devcontainer/Dockerfile
  • mcr.microsoft.com/vscode/devcontainers/php 0-8-bullseye
github-actions
.github/workflows/php.yml
  • actions/checkout v3
  • actions/cache v3
  • davidlienhard/php-simple-lint 1
  • symfonycorp/security-checker-action v5
.github/workflows/pr.yml
  • actions/checkout v3
  • actions/setup-node v2-beta
  • beemojs/conventional-pr-action v2

  • Check this box to trigger a request for Renovate to run again on this repository

Add option to bump version to composer.json file

The idea is to bump the version number in a key in the composer.json file to specify the package version. Like does the standard-version.

Command example

php vendor/bin/conventional-changelog --ver="1.9.11" --bump

composer.json output example

{
  "name": "marcocesarato/php-conventional-changelog",
  "version": "1.9.11",
  "type": "library",
  "license": "GPL-3.0-or-later",
  ...
}

Disable composer.json update

Hi, when I execute $ vendor/bin/conventional-changelog --history the version key is added to composer.json.
Is there an option to disable this ? (I looked and I can't found anything).

The reasons are:

  • We use 2 spaces as tabulation in composer.json, but vendor/bin/conventional-changelog forces to use 4 spaces. So all lines are modified. (FYI tabulation is respected when we install new dependencies with composer).
  • The hash in composer.lock is not updated, so $ composer validate throws an error. I can execute $ composer update but I don't want to update all my dependencies.
  • Not everybody in my team uses vendor/bin/conventional-changelog, so version in composer.json will be inconsistent with reality. (we only want to create a changelog file, and not to create an actual release)

Maybe an option like --composer/--no-composer might be useful. Than you :)

Previous release still tagged as 'latest'

I noticed there's a v1.7.1 release, but v1.7.0 is still marked as 'latest'

image

image

It's not important, but just checking whether this is intentional or just the result of a missed checkbox somewhere.

BREAKING CHANGE footer not being used

Sometimes a BREAKING CHANGE footer is required to properly describe what actually is the breaking change that was needed to develop a feature. It seems this package ignores that and always puts the commit message as a breaking change instead of a feature. If I remove the exclamation mark it seems to ignore that it is a BREAKING CHANGE alltogether.

Am I doing something wrong or is this a known issue (or even a choice)?

The --history argument does not include commits that are ahead of last tag

It would seem that when using generator with --history option, any commit that is currently ahead of last tag will be skipped.

Let's imagine that we created a tag v1.2.3 on 2021-01-01 and then keep making new commits for the next 2 weeks.
After running the --history option, the changelog will contain everything up to v1.2.3. The commits made after 2021-01-01, that are not an ancestor of a tag, will not be shown.

Maybe these commits should probably be marked with unreleased version entry?

Feature Request: Limit commits/tag of current branch

We have a repo that has 2 active branches, one for the current version and one for a soon to be deprecated version.

We've noticed that while running the command with the history flag, it generates the change log but include all the commits between the date range without checking if the commits were made / part of the active branch.

Is there an option to limit the list of commits or tags to the current branch?

Output of changelog for Github Actions.

Love this package!

Do you think it would be useful to have some way of utilising it with github actions by outputting the changelog contents for a specific release? This is so that it can be utilised within a release workflow to add the changelog text into a release body.

Just trying to think of some way this can be incorporated without getting in the way and looking for ideas.

Thanks

New getLastTag logic doesn't find my beta tags

The new logic which was implemented in #47 by @marcocesarato doesn't find previous beta tags. In my repository I have only alpha and beta versions now, like v2.0.0-beta.8. I don't have v2.0.0 now, because the code is not in this phase yet.
But the preg_grep fiters out every tag which contains -

$tagsFound = preg_grep('/^' . $prefixQuote . '[^-]*$/', $tagsArray);

Why this logic was implemented? I can't create v2.0.0-beta.9 version because of this logic.

Tag bump after having created a release candidate tag

Hi @marcocesarato ,

thanks for this library :)
I noticed a bug when I try to create a "release tag" after having created a "release candidate tag".

Let's suppose a repo with one tag named v1.0.0:

  • if I run the following command php vendor/bin/conventional-changelog --rc --commit, tag v1.0.1-rc.1 is created โœ…
  • then if I run php vendor/bin/conventional-changelog --commit, tag v1.0.2-rc.1 is created โŒ

It seems that the library doesn't check if the last tag created is a release candidate or not.

New Feature Release

Hi,

I'd like to use the features created from #19 in one of my projects but would rather depend on stable releases. Just wondering if this could be published as a 1.12 release please?

Thank you

Missing blank line between changeLogVersionHeading and changelog content

Markdown specs specify that headings should have blank lines before and after them ref https://www.markdownguide.org/basic-syntax/

This package doesn't do that see https://raw.githubusercontent.com/marcocesarato/php-conventional-changelog/main/CHANGELOG.md

## [1.15.0](https://github.com/marcocesarato/php-conventional-changelog/compare/v1.14.1...v1.15.0) (2022-06-02)
### Features

We can prevent this by adding the blank line after heading in config with 'changelogVersionFormat' => '## [{{version}}] - {{date}}'."\n", but maybe it would be better if the package does it by default. We can do that by adding ."\n" here https://github.com/marcocesarato/php-conventional-changelog/blob/main/src/Changelog.php#L366

Any thought about this ? Would you like a PR for that ?

Annotated and signed tags

Hello,

First of all, it is really nice and useful project! ๐Ÿ‘

Are there any future plans (or maybe possible configuration which I have overlooked) to create annotated tags instead of lightweight tags; and also to sign them?

Composer update when releasing a new version

Hi @marcocesarato,
Since commit ea8fb7e, composer update is run automatically when releasing a new version.
Updating the dependecies is not always trivial, it can lead to unexpected bugs and I think that its outside this package boundaries.
May I ask you why you decided to run composer update when creating releases?

Thanks

Symfony older version support

Hello there !

I was wondering if it was possible to handle a 3.4 symfony version ?

I am stucked by the symfony/console 4+ restriction.

Thanks !

parseRemoeUrl Regex not working well for specifics repository urls

Hi Marco, how're you ? Thanks for this project!
Its will place our project at other level about documentation!

Now, the problem lol, look this URL of my company private repo:
http://[email protected]:7990/scm/site/name-of-repo.git

Its doesnt fit at your first regex option (where should fit), because named group "owner|repository" doenst accept dash or slash :
#^(?P<protocol>https?|git|ssh|rsync)\://(?:(?P<user>.+)@)*(?P<host>[a-z0-9_.-]*)[:/]*(?P<port>[\d]+){0,1}(?P<pathname>\/((?P<owner>[\w\-]+)\/)?((?P<repository>[\w\-\.]+?)(\.git|\/)?)?)$#smi

It's possible to adjust or create another regex option (maybe another item in .changelog options to add custom regex's.

Thanks in advanced!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.