tbump icon indicating copy to clipboard operation
tbump copied to clipboard

Multi-line regex support for search pattern

Open achary opened this issue 4 years ago • 4 comments

First, thanks for this nice tool. I exactly understand your motivation for switching from bumpversion and I admit that solving various workflow and integration issues (like incorporating change log generation in the same transaction) became nice and easy with tbump.

Now to the issue. I'm using the tool to support version tracking for project, where a single line match is not ambiguity-free. Eg. the version is stored as:

[[package]]
name = "my-project"
version = "1.1.0"

along with references to other thirdparty packages, let's say:

[[package]]
name = "rustc-hash"
version = "1.1.0"

[[package]]
name = "scopeguard"
version = "1.1.0"

Making a search formula in tbump.toml to bump only the my-project version string to 1.2.0 is currently not possible IMO.

I suggest supporting multi-line regex, so things like \n line ending could be added to make unique matches possible in situations like this:

search = '^name = "my-project"\nversion = "{current_version}"'

achary avatar Feb 07 '21 15:02 achary

Here is a PR for review for it: #98.

achary avatar May 21 '21 18:05 achary

I just realized something - are you using tbump to bump lines inside a Cargo.lock file?

If so, what you can do instead is use tbump to change lines in the Cargo.toml configuration file, and use a [[before_commit]] hook to generate the lock file.

See tbump.toml for ruplacer for an example.

dmerejkowsky avatar May 24 '21 10:05 dmerejkowsky

Actualy no, I don't plan using tbump for Cargo.lock files - as a matter of fact, I think these should be left for cargo to take care of. My only focus here was with supporting version bumping in Cargo.toml files alone. And yes, the [[before_commit]] is very helpful here, as any re-build triggered prior a commit will make Cargo.lock becoming updated automatically.

achary avatar May 25 '21 21:05 achary

Cool - just checking :)

dmerejkowsky avatar May 26 '21 11:05 dmerejkowsky