question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support search= with newlines

See original GitHub issue

I am new to bumpversion. When I understand it right, it is only possbile to search for complete version strings, right?

Isn’t it possible to handle code like this?

_APPVER_MAJOR = 0
_APPVER_MINOR = 0
_APPVER_REVISION = 1

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
perituscommented, Oct 30, 2015

Ok, so this is how it could work:

vars.py

_APPVER_MAJOR = 0
_APPVER_MINOR = 0
_APPVER_REVISION = 1

.bumpversion.cfg

current_version = 0.0.1

[bumpversion:file:vars.py]
parse = _APPVER_MAJOR = (?P<major>\d+)\n_APPVER_MINOR = (?P<minor>\d+)\n_APPVER_REVISION = (?P<patch>\d+)
serialize = _APPVER_MAJOR = {major}\n_APPVER_MINOR = {minor}\n_APPVER_REVISION = {patch}

However, when executing that, search doesn’t support multiline yet:

$> bumpversion major --v
Reading config file .bumpversion.cfg:
[bumpversion]
current_version = 0.0.1

[bumpversion:file:vars.py]
parse = _APPVER_MAJOR = (?P<major>\d+)\n_APPVER_MINOR = (?P<minor>\d+)\n_APPVER_REVISION = (?P<patch>\d+)
serialize = _APPVER_MAJOR = {major}\n_APPVER_MINOR = {minor}\n_APPVER_REVISION = {patch}


Parsing version '0.0.1' using regexp '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)'
Parsed the following values: major=0, minor=0, patch=1
Attempting to increment part 'major'
Values are now: major=1, minor=0, patch=0
Parsing version '1.0.0' using regexp '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)'
Parsed the following values: major=1, minor=0, patch=0
New version will be '1.0.0'
Asserting files vars.py contain the version string:
Traceback (most recent call last):
  File "/usr/local/bin/bumpversion", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/bumpversion/__init__.py", line 912, in main
    f.should_contain_version(current_version, context)
  File "/usr/local/lib/python2.7/dist-packages/bumpversion/__init__.py", line 208, in should_contain_version
    assert self.contains(version.original), msg
AssertionError: Did not find '0.0.1' or '_APPVER_MAJOR = 0\n_APPVER_MINOR = 0\n_APPVER_REVISION = 1' in file vars.py

but it should.

0reactions
luckydonaldcommented, Dec 1, 2015

Maybe \ at the end of a line, to escape the invisible newline character?

search = _APPVER_MAJOR = 0\
_APPVER_MINOR = 0\
_APPVER_REVISION = 1

Or, wrap text quotes or something similar. So you can explicitly include newlines.

search = "_APPVER_MAJOR = 0
_APPVER_MINOR = 0
_APPVER_REVISION = 1"

Maybe it is another problem, but the current config doesn’t need quotes, they even get striped. With that you can’t search for "1.0.1" with leaving 1.0.1 alone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I include newlines in a search in less? - Super User
You can do: /pattern$. The pattern replacing pattern , but the $ must stay, it tells the search to look for the pattern,...
Read more >
Find and replace with a newline in Visual Studio Code
In the local searchbox ( ctrl + f ) you can insert newlines by pressing ctrl + enter . Image of multiline search...
Read more >
Find and replace with a newline in Visual Studio Code
In the local searchbox ( Ctrl + F ) you can insert newlines by pressing Ctrl + Enter . multiple-line-support.gif (Local searchbox).
Read more >
Way to do do search/replace adding linebreaks?
Type replacement pattern: for line break it will be \n. Hit "Replace" or "Replace All". 7.
Read more >
vim search around line breaks - Unix & Linux Stack Exchange
I personally would use [ \t\n]* instead of spaces. This will match on zero or more of ' ', tab, and newline. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found