Skip to content

No tag found to do an incremental changelog #463

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

Closed
12rambau opened this issue Dec 17, 2021 · 26 comments
Closed

No tag found to do an incremental changelog #463

12rambau opened this issue Dec 17, 2021 · 26 comments
Labels
issue-status: wait-for-implementation maintainers agree on the bug / feature type: bug

Comments

@12rambau
Copy link
Contributor

12rambau commented Dec 17, 2021

Description

I want to use commitizen in my repository and automatically bump vresion to pipy (and maybe someday conda-forge). Looking at the documentation I started with github actions that are still not compatible with my repository structure (I have a main branch and I'm working directly on it).

So I wanted to go with the CLI that looks exactly like what i needed:

I created a .cz.yaml file:

commitizen:
  changelog_file: CHANGELOG.md
  changelog_incremental: true
  changelog_start_rev: v0.12.9
  name: cz_conventional_commits
  tag_format: v$major.$minor.$patch$prerelease
  update_changelog_on_bump: true
  version: 0.12.10
  version_files:
  - setup.py:version
  - ost/__init__.py:__version__ 

and did little modifications

Steps to reproduce

When I run cz bump I get the following error message:

No tag found to do an incremental changelog

If I clean the changelog.md file, it works but I then only have the latest tag and not the previous one.

So I changed the .cz.yaml file to bump the changelog in a second step:

update_changelog_on_bump: false

Then the tag is created but running cz changelog end up with the same error message.
When I print my tags they are all here even some that I don't want to use:

$ git tag 

0.10.1
0.12.5
0.12.6
0.9.4
v0.12.10
v0.12.7
v0.12.8
v0.12.9

It looks like a chicken & egg problem, what did I miss in my configuration?

Environment

Commitizen Version: 2.20.2
Python Version: 3.8.3 (default, Oct 14 2020, 12:53:46)
[Clang 11.0.3 (clang-1103.0.32.29)]
Operating System: Darwin

@woile
Copy link
Member

woile commented Dec 17, 2021

I cloned your repo, and I think your main issue is the tag_format, which includes a v now.
I changed it like this:

-  tag_format: v$major.$minor.$patch$prerelease
+ tag_format: $major.$minor.$patch$prerelease

And then created the missing tag (0.12.9).
After that when doing cz bump it works (you still have to create a new commit because there won't be any).

Let me know if this helps, because in your examples there are tags that are not available in the repo you linked.

@12rambau
Copy link
Contributor Author

ok now I wrapped my head around it. I was (naively) thinking that tags were pushed to distant repo but nope. So these tags are only existing on my local creating all sort of isssues (actions not triggered), previous tag not existing etc...

Now that the workflow is clearer to me, it works like a charm. thanks for the guidance !

@woile
Copy link
Member

woile commented Dec 17, 2021

Great news!
What we usually do is let the github action create the tag and then push back to the repo.
Here's the tutorial for github actions: https://commitizen-tools.github.io/commitizen/tutorials/github_actions/

@12rambau
Copy link
Contributor Author

I'm waiting for this issue to be solved as I'm using a main branch

@12rambau 12rambau reopened this Jan 11, 2022
@12rambau
Copy link
Contributor Author

12rambau commented Jan 11, 2022

I'm reopening the issue because it's the exact same problem in another repository. I thought I had understand but it seems I didn't...

So in this repository: https://github.com/12rambau/sepal_ui I wanted to do the exact same thing: create the changelog on bump.

currently I'm not. I tried to add to folowing in my .cz.yaml file:

changelog_incremental: true
update_changelog_on_bump: true

But I'm getting the exact same error:

No tag found to do an incremental changelog

This time I checked my tags and they should all be here with a v_*.*.* value, the last one being v_2.5.3. So what am I missing this time ?

@woile
Copy link
Member

woile commented Jan 12, 2022

It works fine on my side. I cloned, run cz bump and the tag created was v_2.5.3 with the changelog.

My conf:

$ cz version
2.17.11

on ubuntu

@12rambau
Copy link
Contributor Author

I think that's because I had manually updated the changelog file. I deleted it on the 2.6.2 release and everything came back to normal

Ingerid added a commit to NationalLibraryOfNorway/DHLAB that referenced this issue May 16, 2022
- as suggested here:
commitizen-tools/commitizen#463 (comment)

Signed-off-by: Ingerid Dale <ingerid.dale@nb.no>
@12rambau
Copy link
Contributor Author

Sorry to reopen it again but I fail to get it every time I want to use the cz bump command it fails because of the changelog (which the main feature of cz for me). All the solutions I found so far are small patches from my side but I would like to better understand what's behinf this error message.

So still the same old problem, I changed stuff in my repository sepal_ui and on a fresh clone and I run cz bump, result:

bump: version 2.9.4 → 2.10.0
tag to create: v_2.10.0
increment detected: MINOR

No tag found to do an incremental changelog

which is again not working. looking at the tags:
the last one is v_2.9.4 which should work. could you clone my repository and simply help me diagnose what's wrong ?

@12rambau 12rambau reopened this Jul 18, 2022
@12rambau
Copy link
Contributor Author

I digged a bit in the lib and it seems the problem for me is coming from the way commitizen is recognizing tags in the tag list.

SIMILARITY_THRESHOLD = 0.89

I printed the partial result of the evaluation from my side:

bump: version 2.9.4 → 2.10.0
tag to create: v_2.10.0
increment detected: MINOR

["v_2.9.4: (0.8333333333333334, GitTag('v_2.9.4', 'b01d653a693c700675034e94bdb014cc1ae75afb', '2022-06-09'))"

That's the latest but as .83 < .89 I get an error.

Would it be possible to reduce the value to let's say .8 ? and add my example to the tests ?

@woile
Copy link
Member

woile commented Jul 21, 2022

think that would be possible, do you think you could add some extra examples?

@12rambau
Copy link
Contributor Author

12rambau commented Jul 21, 2022

I'll look at the test structure to see if I can generate more exotic version convention (vers_, version., v- etc) and check how they behave with the current value

@Lee-W
Copy link
Member

Lee-W commented Jul 22, 2022

@woile if such error could happen, do you think we should make that values configurable 🤔

@12rambau
Copy link
Contributor Author

that would be super difficult for users to guess what is the appropriate value. plus if you decrease the value to much you'll may end up with a result that is not the expected one. IMO that is safer to build the test with exotic version conventions and add one if somebody have a weird idea (like "v_" in my case). It ensures that the value is as high as possible.

@Lee-W
Copy link
Member

Lee-W commented Jul 23, 2022

Sounds great! maybe we could list what we have tested, so the next time we want to change the value we'll have a better idea on why we decide to use that value from the very begining

@souravjamwal77
Copy link

Hi I was trying to run cz bump but it's failing with the same error code. Below is my pyproject.toml file

[tool]
[tool.commitizen]
name = "cz_conventional_commits"
version = "0.0.1"
tag_format = "v$major.$minor.$patch$prerelease"

Also, I'm not setting any git tags, just trying to use cz directly as a PoC for our CI/CD process.
Can anyone suggest, what shall I do?

@Lee-W
Copy link
Member

Lee-W commented Aug 2, 2022

@souravjamwal77 May I know what was the commit types (e.g., feat, fix)? If there's only ci, doc and etc., commitizen won't bump the version. This is the default bump_map

bump_map = OrderedDict(

@12rambau
Copy link
Contributor Author

@Lee-W, I will have the time to work on this in the next 2 weeks, where would you like me to write the tests and is there already an example where you create a fake changelog with a normal version tree (to get some inspiration) ?

@Lee-W
Copy link
Member

Lee-W commented Jan 18, 2023

@mmorley0395
Copy link

mmorley0395 commented Apr 12, 2023

I'm having the same issue, but only on Github actions.. Doing CZ bump locally seems to work, but using the github actions setup always seems to yield:

 cz --no-raise 21 bump --yes --changelog --check-consistency --changelog-to-stdout >CHANGELOG.md
bump: version 0.1.0 → 0.1.1
tag to create: 0.1.1
increment detected: PATCH

No tag found to do an incremental changelog

Can someone take a look at my repo and settings to see why this might be? link I've tried setting the tag format both with and without a v, but nothing seems to fix it.

-- EDIT
I found a fix for my case (which was more a github CI yml issue than the issues listed here, but threw the same error message), I had changed the "body.md" file in the example yml, because i thought it should be the name of your changelog, but that's not the case. changing back to body.md fixed it. I also had to add a permissions:write setting in the yml file to properly push the new release, otherwise the bump occurred in github ci but not the release.

@woile
Copy link
Member

woile commented Apr 28, 2023

I've updated the docs for github actions. I think this issue shouldn't be happening anymore.

Try using latest actions/checkout@v3 and latest commitizen

@woile woile closed this as completed Apr 28, 2023
@jjfantini
Copy link

I had changed from body.md to CHANGELOG.md, and I am still getting this error using the Github action.

Settings:

[tool.commitizen]
name = "cz_conventional_commits"
version = "0.1.8"
tag_format = "v$version"
update_changelog_on_bump = true
annoted_tag = true
major_version_zero = true
version_files = [
    "pyproject.toml:^version",
    "./src/humbl-data/__version__.py"
]

Github Action:

name: Bump version

on:
  push:
    branches:
      - master

permissions:
  contents: write

jobs:
  bump-version:
    if: "!startsWith(github.event.head_commit.message, 'bump:')"
    runs-on: ubuntu-latest
    name: "Bump version and create changelog with commitizen"
    steps:
      - name: Check out
        uses: actions/checkout@v3
        with:
          token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
          fetch-depth: 0
      - name: Create bump and changelog
        uses: commitizen-tools/commitizen-action@master
        with:
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          changelog_increment_filename: CHANGELOG.md
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          name: humbl-data v${{ env.REVISION }}
          body_path: "CHANGELOG.md"
          tag_name: v${{ env.REVISION }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Bump version

on:
  push:
    branches:
      - master

permissions:
  contents: write

jobs:
  bump-version:
    if: "!startsWith(github.event.head_commit.message, 'bump:')"
    runs-on: ubuntu-latest
    name: "Bump version and create changelog with commitizen"
    steps:
      - name: Check out
        uses: actions/checkout@v3
        with:
          token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
          fetch-depth: 0
      - name: Create bump and changelog
        uses: commitizen-tools/commitizen-action@master
        with:
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          changelog_increment_filename: CHANGELOG.md
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          name: humbl-data v${{ env.REVISION }}
          body_path: "CHANGELOG.md"
          tag_name: v${{ env.REVISION }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}name: Bump version

on:
  push:
    branches:
      - master

permissions:
  contents: write

jobs:
  bump-version:
    if: "!startsWith(github.event.head_commit.message, 'bump:')"
    runs-on: ubuntu-latest
    name: "Bump version and create changelog with commitizen"
    steps:
      - name: Check out
        uses: actions/checkout@v3
        with:
          token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
          fetch-depth: 0
      - name: Create bump and changelog
        uses: commitizen-tools/commitizen-action@master
        with:
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          changelog_increment_filename: CHANGELOG.md
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          name: humbl-data v${{ env.REVISION }}
          body_path: "CHANGELOG.md"
          tag_name: v${{ env.REVISION }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}name: Bump version

on:
  push:
    branches:
      - master

permissions:
  contents: write

jobs:
  bump-version:
    if: "!startsWith(github.event.head_commit.message, 'bump:')"
    runs-on: ubuntu-latest
    name: "Bump version and create changelog with commitizen"
    steps:
      - name: Check out
        uses: actions/checkout@v3
        with:
          token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
          fetch-depth: 0
      - name: Create bump and changelog
        uses: commitizen-tools/commitizen-action@master
        with:
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          changelog_increment_filename: CHANGELOG.md
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          name: humbl-data v${{ env.REVISION }}
          body_path: "CHANGELOG.md"
          tag_name: v${{ env.REVISION }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Everything works fine if I comment out changelog_increment_filename: CHANGELOG.md. I just want the newest changes to be shown for each release, ie incremental?

@jjfantini
Copy link

switching to body.md for both instances fixes the issue

@TijoT
Copy link

TijoT commented May 28, 2024

I was also having similar problem.

`vscode ➜ /workspaces/Project (proj_branch) $ cz bump
bump: version 0.0.1 → 0.1.0
tag to create: v0.1.0
increment detected: MINOR

No tag found to do an incremental changelog`

Deleted the CHANGELOG.md file and committed changes using cz commit. When cz bump is executed, tag is created and CHANGELOG.md file automatically generated.

`Commit successful!
vscode ➜ /workspaces/Project (proj_branch) $ cz bump
bump: version 0.0.1 → 0.1.0
tag to create: v0.1.0
increment detected: MINOR

[proj_branch c7f4000] bump: version 0.0.1 → 0.1.0
4 files changed, 18 insertions(+), 17 deletions(-)

Done!`

@mateusht-ciandt
Copy link

mateusht-ciandt commented Nov 8, 2024

I am facing the same issue when perfoming the first bump with commitizen version: 3.30.0

$ cz bump
Tag 0.0.0 could not be found. 
Possible causes:
- version in configuration is not the current version
- tag_format is missing, check them using 'git tag --list'

? Is this the first tag created? Yes
bump: version 0.0.0 → 0.1.0
tag to create: 0.1.0
increment detected: MINOR

No tag found to do an incremental changelog

Or this

$ cz bump --yes --changelog --check-consistency --git-output-to-stderr --changelog-to-stdout >body.md
bump: version 0.0.0 → 0.1.0
tag to create: 0.1.0
increment detected: MINOR

No tag found to do an incremental changelog

@mrclrchtr
Copy link

the same here and somehow irritating... i have invested quite a lot of time to end up here... can the issue please be reopened?

@Lee-W
Copy link
Member

Lee-W commented Apr 23, 2025

yep, we could open it. I'm kinda out of bandwidth recently. would appreciate if we could have detailed reproducing steps so that I can get into it quicker when I have time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue-status: wait-for-implementation maintainers agree on the bug / feature type: bug
Projects
None yet
Development

No branches or pull requests

9 participants