2

I want to use bump2version for a file that looks like this (it's a rust Cargo.toml):

[package]
name = "my_super_package"
version = "0.1.34"
...
[dependencies]
my_other_super_package = { path = "../yadayadayada", version = "0.1.34", registry = "crates-haha" }
...

In the .bumpversion.cfg file, I cannot just use

[bumpversion:file:Cargo.toml]
parse = qv\((?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)

because that would accidentally also change the unrelated version of my_other_super_package that coincidentally has the same version number.

The bump2version docs say that search and replace can handle multi-line specs, so I tried

[bumpversion:file:Cargo.toml]
search = name = "my_super_package"\nversion = "{current_version}"
replace = name = "my_super_package"\nversion = "{new_version}"

but the newlines didn't seem to be matched. I also tried

[bumpversion:file:Cargo.toml]
parse = qv(^version = \((?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+))

but the "^version = " part seems to be ignored.

Help?

mpersico
  • 766
  • 7
  • 19

1 Answers1

2

wandered same question, and found the answer. File for bumping Cargo.lock and Cargo.toml (so git tree would be clean after VScode autobumping Cargo.lock file), the trick is to use tab symbols (maybe spaces will work as well, didn't test):

[bumpversion:file:Cargo.lock]
search = name = "my-project"
    version = "{current_version}"
replace = name = "my-project"
    version = "{new_version}"

so after bumping you get in Cargo.toml:

[package]
name = "my-project"
version = "1.2.2"
Stazis
  • 73
  • 2
  • 7