peritus / bumpversion

Version-bump your software with a single command
https://pypi.python.org/pypi/bumpversion
MIT License
1.5k stars 148 forks source link

Cannot replace with multiple lines #123

Open dochang opened 8 years ago

dochang commented 8 years ago

It seems that bumpversion doesn't work with multiline string.

Here is my CHANGELOG.md:

## Unreleased ##

  - xxxx

## 0.0.2 -- 2015-12-08 ##

  - yyyy

And here is my .bumpversion.cfg:

[bumpversion:file:CHANGELOG.md]
search = ## Unreleased ##
replace = ## Unreleased ##

  ## {new_version} - {utcnow:%Y-%m-%d} ##

After running bumpversion, the expected changelog is:

## Unreleased ##

## 0.0.3 -- 2015-12-09 ##

  - xxxx

## 0.0.2 -- 2015-12-08 ##

  - yyyy

But the actual content is:

## Unreleased ##
## 0.0.3 -- 2015-12-09 ##

  - xxxx

## 0.0.2 -- 2015-12-08 ##

  - yyyy

And .bumpversion.cfg is changed:

[bumpversion:file:CHANGELOG.md]
search = ## Unreleased ##
replace = ## Unreleased ##
        ## {new_version} - {utcnow:%Y-%m-%d} ##

Bumpversion removes the empty line.

How to replace current version with multiline string?

kdeldycke commented 8 years ago

This looks similar to #103, right ? I mean, the underlying issue seems to be the lack of proper multi-line support in parameters of bumpversion's own configuration blocks. There's probably a textwrap()to add somewhere in bumpversion config parsing.

dochang commented 8 years ago

Yes, RawConfigParser in py2 doesn't recognize empty lines in multiple lines.

Instead of wrapping RawConfigParser, shall we switch to another parser, e.g., a toml parser?

nhomar commented 8 years ago

It happens to me too.

The fact that you can use to drop directly the changelog the multiline with blank lines is mandatory for md and rst formats.

aiguofer commented 6 years ago

Heh, came here for exactly the same reason, trying to add my CHANGELOG release into versionbump...

Has anyone figured out a way to get that extra newline in there between the unreleased and the release?

aiguofer commented 6 years ago

Just in case this is helpful to someone that finds this: