mirror of
https://github.com/TECHNOFAB11/bump2version.git
synced 2025-12-12 16:10:07 +01:00
Compare commits
No commits in common. "main" and "1.1.0" have entirely different histories.
7 changed files with 11 additions and 29 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
current_version = "1.1.1"
|
current_version = "1.1.0"
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
message = "chore: bump {current_version} → {new_version}"
|
message = "chore: bump {current_version} → {new_version}"
|
||||||
|
|
|
||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -61,7 +61,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bump2version"
|
name = "bump2version"
|
||||||
version = "1.1.1"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"regex",
|
"regex",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bump2version"
|
name = "bump2version"
|
||||||
version = "1.1.1"
|
version = "1.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "⬆️ Easily manage version numbers in your projects."
|
description = "⬆️ Easily manage version numbers in your projects."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,6 @@ pub(crate) struct Cli {
|
||||||
#[arg(short = 'n', long = "dry-run", default_value_t = false)]
|
#[arg(short = 'n', long = "dry-run", default_value_t = false)]
|
||||||
pub(crate) dry_run: bool,
|
pub(crate) dry_run: bool,
|
||||||
|
|
||||||
/// Current version
|
|
||||||
#[arg(long = "current-version", value_name = "VERSION")]
|
|
||||||
pub(crate) current_version: Option<String>,
|
|
||||||
|
|
||||||
/// New version that should be in the files.
|
/// New version that should be in the files.
|
||||||
#[arg(long = "new-version", value_name = "VERSION")]
|
#[arg(long = "new-version", value_name = "VERSION")]
|
||||||
pub(crate) new_version: Option<String>,
|
pub(crate) new_version: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use serde_derive::Deserialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub(crate) struct Config {
|
pub(crate) struct Config {
|
||||||
pub(crate) current_version: Option<String>,
|
pub(crate) current_version: String,
|
||||||
pub(crate) message: Option<String>,
|
pub(crate) message: Option<String>,
|
||||||
pub(crate) commit: bool,
|
pub(crate) commit: bool,
|
||||||
pub(crate) tag: bool,
|
pub(crate) tag: bool,
|
||||||
|
|
|
||||||
21
src/main.rs
21
src/main.rs
|
|
@ -38,23 +38,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let current_version = args
|
let current_version = config.current_version.clone();
|
||||||
.current_version
|
|
||||||
|
let attempted_new_version = args
|
||||||
|
.new_version
|
||||||
.clone()
|
.clone()
|
||||||
.or(config.current_version.clone());
|
.or(attempt_version_bump(args.clone(), config.clone()));
|
||||||
|
|
||||||
if current_version.is_none() {
|
|
||||||
error!("No current version could be determined, either set in config or pass as arg");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let current_version = current_version.unwrap();
|
|
||||||
|
|
||||||
let attempted_new_version = args.new_version.clone().or(attempt_version_bump(
|
|
||||||
args.clone(),
|
|
||||||
config.clone(),
|
|
||||||
current_version.clone(),
|
|
||||||
));
|
|
||||||
|
|
||||||
if attempted_new_version.is_some() {
|
if attempted_new_version.is_some() {
|
||||||
let new_version = attempted_new_version.clone().unwrap();
|
let new_version = attempted_new_version.clone().unwrap();
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,7 @@ use std::collections::HashMap;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
use tracing::{error, trace};
|
use tracing::{error, trace};
|
||||||
|
|
||||||
pub(crate) fn attempt_version_bump(
|
pub(crate) fn attempt_version_bump(args: Cli, config: Config) -> Option<String> {
|
||||||
args: Cli,
|
|
||||||
config: Config,
|
|
||||||
current_version: String,
|
|
||||||
) -> Option<String> {
|
|
||||||
let parse_regex = config.parse;
|
let parse_regex = config.parse;
|
||||||
let regex = match Regex::new(&parse_regex) {
|
let regex = match Regex::new(&parse_regex) {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
|
|
@ -20,6 +16,7 @@ pub(crate) fn attempt_version_bump(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let current_version = config.current_version;
|
||||||
let mut parsed: HashMap<String, String> = HashMap::new();
|
let mut parsed: HashMap<String, String> = HashMap::new();
|
||||||
|
|
||||||
if let Some(captures) = regex.captures(¤t_version) {
|
if let Some(captures) = regex.captures(¤t_version) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue