Giter Club home page Giter Club logo

Comments (8)

peritus avatar peritus commented on August 20, 2024

So, you want your version in "{major}", "{minor}", "{patch}" format ?

Should be as simple as configuring like this:

serialize = "{major}", "{minor}", "{patch}"
parse = "(?P<major>\d+)", "(?P<minor>\d+)", "(?P<patch>\d+)"

.. please report back if it isn't or I didn't understand your issue report correctly.

from bumpversion.

saschpe avatar saschpe commented on August 20, 2024

Ah, didn't know that. So I got this .bumpversion.cfg:

 [bumpversion]
 serialize = "{major}", "{minor}", "{patch}"
 parse = "(?P<major>\d+)", "(?P<minor>\d+)", "(?P<patch>\d+)"
 current_version = 0.1.4
 files = rapport/__init__.py
 commit = True
 tag = True

But:

rapport% bumpversion patch
Traceback (most recent call last):
  File "/usr/bin/bumpversion", line 9, in <module>
    load_entry_point('bumpversion==0.3.6', 'console_scripts', 'bumpversion-2.7')()
  File "/usr/lib/python2.7/site-packages/bumpversion/__init__.py", line 377, in main
    args.current_version, path)
AssertionError: Did not find string 0.1.4 in file rapport/__init__.py

from bumpversion.

peritus avatar peritus commented on August 20, 2024

if you choose a different format (other than the default {major}.{minor}.{patch}), you need to specify your version in that format.

The following should do the trick:

current_version = "0", "1", "4"

from bumpversion.

saschpe avatar saschpe commented on August 20, 2024

Yeah, just found out myself, but:

/usr/lib/python2.7/site-packages/bumpversion/__init__.py:198: UserWarning: '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)' does not parse current version
  warnings.warn("'{}' does not parse current version".format(self.parse_regex.pattern))
/usr/lib/python2.7/site-packages/bumpversion/__init__.py:212: UserWarning: Did not find key u'major' in {} when serializing version number
  repr(e.message), repr(self._parsed)))
Traceback (most recent call last):
  File "/usr/bin/bumpversion", line 9, in <module>
    load_entry_point('bumpversion==0.3.6', 'console_scripts', 'bumpversion-2.7')()
  File "/usr/lib/python2.7/site-packages/bumpversion/__init__.py", line 387, in main
    after = before.replace(args.current_version, args.new_version)
TypeError: coercing to Unicode: need string or buffer, NoneType found

seems like parsing .bumpversion.cfg ignores "parse". The following works though:

% bumpversion patch --parse '"(?P<major>\d+)", "(?P<minor>\d+)", "(?P<patch>\d+)"'
[master 50e81ea] Bump version: "0", "1", "4" → 0.1.5
 2 files changed, 3 insertions(+), 2 deletions(-)

However, afterwards, .bumpversion.cfg looks like this:

[bumpversion]
 serialize = "{major}", "{minor}", "{patch}"
 parse = "(?P<major>\d+)", "(?P<minor>\d+)", "(?P<patch>\d+)"
 current_version = 0.1.5
 files = rapport/__init__.py
 commit = True
 tag = True

So "serialize" seems to be ignored too

from bumpversion.

peritus avatar peritus commented on August 20, 2024

You probably need to escape the quotes.

from bumpversion.

peritus avatar peritus commented on August 20, 2024

On the other hand:

>>> import ConfigParser
>>> import io
>>> sample_config = """
... [mysqld]
... current_version = "0", "1", "4"
... """
>>> config = ConfigParser.RawConfigParser(allow_no_value=True)
>>> config.readfp(io.BytesIO(sample_config))
>>> config.get('mysqld')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: get() takes exactly 3 arguments (2 given)
>>> config.get('mysqld', 'current_version')
'"0", "1", "4"'
>>>

looks pretty good.

from bumpversion.

peritus avatar peritus commented on August 20, 2024

#26 is a valid issue, but won't work today, thanks for that!

What about

__version_info__ = tuple("0.1.4".split("."))
__version__ = ".".join(__version_info__)

and using the default serialize/parse options ?

That should have the same effect (although not as elegant on the bumpversion side ;) ).

from bumpversion.

saschpe avatar saschpe commented on August 20, 2024

Yeah, I guess that would work meanwhile. But there's other code that does this which is not under my control :-)

from bumpversion.

Related Issues (20)

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.