diff --git a/.bumpversion.toml b/.bumpversion.toml index b9a9e7f..3893965 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,4 +1,4 @@ -current_version = "1.0.2" +current_version = "1.1.0" commit = true tag = true message = "chore: bump {current_version} → {new_version}" @@ -11,8 +11,8 @@ type = "string" values = ["alpha", "beta", "stable"] [file."Cargo.toml"] -format = 'version = "{version}"' +formats = ['version = "{version}"'] [file."Cargo.lock"] -format = """name = "bump2version" -version = "{version}"""" +formats = ["""name = "bump2version" +version = "{version}""""] diff --git a/Cargo.lock b/Cargo.lock index 59f7f97..af2eacd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,7 +61,7 @@ dependencies = [ [[package]] name = "bump2version" -version = "1.0.2" +version = "1.1.0" dependencies = [ "clap", "regex", diff --git a/Cargo.toml b/Cargo.toml index dcff0e0..ea867a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bump2version" -version = "1.0.2" +version = "1.1.0" edition = "2021" description = "⬆️ Easily manage version numbers in your projects." license = "MIT" diff --git a/src/config.rs b/src/config.rs index 1384979..125da3f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -35,8 +35,8 @@ pub(crate) struct Part { #[derive(Debug, Clone, Deserialize)] pub(crate) struct File { - /// Format to replace, eg. `current_version = "{version}"` - pub(crate) format: String, + /// Formats to replace, eg. `current_version = "{version}"` + pub(crate) formats: Vec, } fn default_parse() -> String { diff --git a/src/main.rs b/src/main.rs index 5b54806..04d00fd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,22 +84,24 @@ fn main() -> Result<(), Box> { // Update version in specified files info!(amount = &files.len(), "Updating version in files"); for path in files.clone() { - let content = fs::read_to_string(path)?; - let format = &config_files.get(path).unwrap().format.clone(); + let mut content = fs::read_to_string(path)?; + let formats = &config_files.get(path).unwrap().formats.clone(); - let old_line = format.replace("{version}", ¤t_version); - if !content.contains(&old_line) { - warn!( - current_version, - path, "Did not find current version in file" - ); + for format in formats { + let old_line = format.replace("{version}", ¤t_version); + if !content.contains(&old_line) { + warn!( + current_version, + path, "Did not find current version in file" + ); + } + + let new_line = format.replace("{version}", &new_version); + content = content.replace(&old_line, &new_line); } - let new_line = format.replace("{version}", &new_version); - let updated_content = content.replace(&old_line, &new_line); - if !dry_run { - fs::write(path, updated_content)?; + fs::write(path, content)?; } }