your-tools / tbump

Bump software releases
BSD 3-Clause "New" or "Revised" License
158 stars 22 forks source link

Multi-line regex support for search pattern #83

Open achary opened 3 years ago

achary commented 3 years ago

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 commented 3 years ago

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

dmerejkowsky commented 3 years ago

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.

achary commented 3 years ago

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.

dmerejkowsky commented 3 years ago

Cool - just checking :)