mbarkhau / bumpver

BumpVer: Automatic Versioning
https://github.com/mbarkhau/bumpver
MIT License
199 stars 36 forks source link

Allow multi-line patterns #193

Open quad opened 2 years ago

quad commented 2 years ago

Our Rust project needs to bump a version in a Cargo.lock file. The contents looks something like:

[[package]]
name = "uuid"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83"
dependencies = [
 "serde",
]

[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "our-package"
version = "0.1.3"
dependencies = [
 "uuid",
 "version_check",
]

We want to only want to bump our-package's version. However, if we match upon version = "{version"} then there's the potential that we match and bump a package that isn't our-package.

It would be nice if a pattern could be multi-line and thus we could write: 'name = "our-package"\nversion = "{version}"'

mbarkhau commented 2 years ago

I understand your request. Unfortunately, I originally wrote the matching code in a very line oriented way, so this will likely require a refactoring. You can have a look at some of the code here:

https://github.com/mbarkhau/bumpver/blob/master/src/bumpver/v2rewrite.py

Would you be interested in working on a PR for this?