c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.05k stars 134 forks source link

Bump2version is erroring when listing the current version and there is no value to replace in the file. #181

Open cowboy-cod3r opened 3 years ago

cowboy-cod3r commented 3 years ago

Hi,

I use this product for quite a bit of projects. Thanks for keeping it up to date.

I recently upgraded from 1.0.0 to 1.0.1 and started getting some errors.

Issue When attempting to get the current version, when there is no value to replace in one of my managed version files, I started getting this error:

# bump2version patch --allow-dirty --dry-run --list | grep current_version | awk -F "=" 'NR==1 { print $2 }'
Traceback (most recent call last):
  File "/Users/user1/opt/anaconda3/envs/myapp/bin/bump2version", line 8, in <module>
    sys.exit(main())
  File "/Users/user1/opt/anaconda3/envs/myapp/lib/python3.8/site-packages/bumpversion/cli.py", line 124, in main
    _check_files_contain_version(files, current_version, context)
  File "/Users/user1/opt/anaconda3/envs/myapp/lib/python3.8/site-packages/bumpversion/cli.py", line 618, in _check_files_contain_version
    f.should_contain_version(current_version, context)
  File "/Users/user2/opt/anaconda3/envs/myapp/lib/python3.8/site-packages/bumpversion/utils.py", line 68, in should_contain_version
    raise VersionNotFoundException(
bumpversion.exceptions.VersionNotFoundException: Did not find 'versionToken' in file: 'deploy/files/versions.csv'

The above error is correct in that versionToken does not exist in the file deploy/files/versions.csv. Prior to v1.0.1 being released though it would ignore that and return me the current version. Here is an example of it working with version 1.0.0.

bump2version patch --allow-dirty --dry-run --list | grep current_version | awk -F "=" 'NR==1 { print $2 }'
1.0.3

As part of my own CI process, I have a requirement to get the current version of the product I'm building so that I can name things appropriately based on version which is why I'm trying to get the current version. Is there a better approach to get the current version?

florisla commented 3 years ago

Hi,

Would this proposed feature work for you? https://github.com/c4urself/bump2version/issues/57

cowboy-cod3r commented 3 years ago

Yes, I believe that would work. Thanks!