Title: Inconsistent changelog behavior based on rev-range & merge strategy · Issue #660 · commitizen-tools/commitizen · GitHub
Open Graph Title: Inconsistent changelog behavior based on rev-range & merge strategy · Issue #660 · commitizen-tools/commitizen
X Title: Inconsistent changelog behavior based on rev-range & merge strategy · Issue #660 · commitizen-tools/commitizen
Description: Description We are running into inconsistent behavior of the changelog command depending on the rev-range used when we have a branch with different merge commits. The reason is that when generating the changelog, commitizen is using the ...
Open Graph Description: Description We are running into inconsistent behavior of the changelog command depending on the rev-range used when we have a branch with different merge commits. The reason is that when generating...
X Description: Description We are running into inconsistent behavior of the changelog command depending on the rev-range used when we have a branch with different merge commits. The reason is that when generating...
Opengraph URL: https://github.com/commitizen-tools/commitizen/issues/660
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistent changelog behavior based on rev-range \u0026 merge strategy","articleBody":"### Description\r\n\r\nWe are running into inconsistent behavior of the changelog command depending on the rev-range used when we have a branch with different merge commits.\r\n\r\nThe reason is that when generating the changelog, commitizen is using the author-date-order ([see here](https://github.com/commitizen-tools/commitizen/blob/master/commitizen/commands/changelog.py#L147-L149))\r\n\r\nThis means that in the scenario where you merge using a non-linear merge strategy (which is often the default), then the changelog command become inconsistent. (See examples below)\r\n\r\n### Steps to reproduce\r\n\r\nHere is an example (you can find this example in a test github repo [here](https://github.com/sacha-c/commitizen_changelog_bug_example):\r\n\r\n1. Create a main branch with an initial commit with commitizen setup \u0026 a `cz bump` commit v0.1.0\r\n2. Create mr 1 off of main \u0026 make a commit\r\n3. Create mr2 off of main \u0026 make a commit\r\n4. Merge mr1 into main with `git merge mr1`\r\n5. Run `cz bump` (tags v0.2.0)\r\n6. Merge mr2 into main with `git merge mr2`\r\n7. Run `cz bump` (tags v0.3.0)\r\n\r\nWe end up with the following git tree:\r\n```bash\r\n(venv) ***@*** commitizen_changelog_bug_example % git log --graph --oneline --all\r\n* a48e0e5 (HEAD -\u003e main, tag: v0.3.0, origin/main) bump: version 0.2.0 → 0.3.0\r\n* d247ed7 Merge branch 'mr2'\r\n|\\ \r\n| * 36b659e (origin/mr2, mr2) feat: mr2\r\n* | 7b97d2c (tag: v0.2.0) bump: version 0.1.0 → 0.2.0\r\n* | 82f3844 (origin/mr1, mr1) feat: mr1\r\n|/ \r\n* 1162498 (tag: v0.1.0) bump: version 0.0.1 → 0.1.0\r\n* e76ef76 feat: initial commit\r\n```\r\n\r\nThe expectation now is for `cz changelog v0.3.0` \u0026 `cz changelog v0.2.0..v0.3.0` to show the same content for `v0.3.0`, but it is not the case. Because commitizen orders commits by author_date, when using a rev-range it is ordering commits by date, which makes the commit from `mr2` erroneously appear in v0.2.0. However when using a single `rev` it appears as expected.\r\nHere is the output of the different commands\r\n\r\n```bash\r\n(venv) ***@*** commitizen_changelog_bug_example % cz changelog v0.3.0 --dry-run\r\n## v0.3.0 (2023-01-26)\r\n\r\n### Feat\r\n\r\n- mr2\r\n\r\n(venv) ***@*** commitizen_changelog_bug_example % cz changelog v0.2.0 --dry-run\r\n## v0.2.0 (2023-01-26)\r\n\r\n### Feat\r\n\r\n- mr1\r\n\r\n(venv) ***@*** commitizen_changelog_bug_example % cz changelog v0.2.0..v0.3.0 --dry-run\r\n## v0.3.0 (2023-01-26)\r\n\r\n## v0.2.0 (2023-01-26)\r\n\r\n### Feat\r\n\r\n- mr2\r\n- mr1\r\n```\r\n\r\n### Current behavior\r\n\r\nRunning `cz changelog v0.3.0` \u0026 `cz changelog v0.2.0..v0.3.0` gives a different output under the *v0.3.0* entry\r\n\r\n### Desired behavior\r\n\r\nRunning `cz changelog v0.3.0` \u0026 `cz changelog v0.2.0..v0.3.0` gives the same output under the *v0.3.0* entry\r\n\r\n### Screenshots\r\n\r\n_No response_\r\n\r\n### Environment\r\n\r\nCommitizen Version: 2.40.0\r\nPython Version: 3.10.9 (main, Dec 27 2022, 11:11:24) [Clang 14.0.0 (clang-1400.0.29.202)]\r\nOperating System: Darwin\r\n\r\n### Proposed solutions/ideas\r\nI *think* the solution would be to change\r\n```diff\r\ncommits = git.get_commits(\r\n- start=start_rev, end=end_rev, args=\"--author-date-order\"\r\n+ start=start_rev, end=end_rev, args=\"--topo-order\"\r\n)\r\n```\r\n\r\nBut I suppose this may be breaking to existing changelogs, so I wonder what is your take on this?","author":{"url":"https://github.com/sacha-c","@type":"Person","name":"sacha-c"},"datePublished":"2023-01-26T09:52:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/660/commitizen/issues/660"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dba9572d-49a2-83fd-d8ae-a3907e777a7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E14:307653:9545786:C185BAC:69772222 |
| html-safe-nonce | 7f107933c2391fc00f880deca8e74c79663c3da285e3e1496b8e7afe9d96431d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTE0OjMwNzY1Mzo5NTQ1Nzg2OkMxODVCQUM6Njk3NzIyMjIiLCJ2aXNpdG9yX2lkIjoiODEzNjM3MjcyMDAyODI5NTcxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | daf7ae3f3e51e98b923cb715c8327f4f14a5f5920450cf637f08f36f6dc82b75 |
| hovercard-subject-tag | issue:1557881447 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/commitizen-tools/commitizen/660/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6d484d22aebc1769abaffa907f71304877ed9f9a6f5b9e4b383ec253dd0ecef2/commitizen-tools/commitizen/issues/660 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6d484d22aebc1769abaffa907f71304877ed9f9a6f5b9e4b383ec253dd0ecef2/commitizen-tools/commitizen/issues/660 |
| og:image:alt | Description We are running into inconsistent behavior of the changelog command depending on the rev-range used when we have a branch with different merge commits. The reason is that when generating... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sacha-c |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| turbo-cache-control | no-preview |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f752335dbbea672610081196a1998e39aec5e14b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width