mirror of
https://github.com/TECHNOFAB11/bump2version.git
synced 2025-12-12 08:00:09 +01:00
should bump to version specified by --new-version if present (#3)
* update Cargo.lock * better error message when failed to get current version from config * should bump to version specified by --new-version if present * fix: update docs && add CI --------- Co-authored-by: 莫仲华 <mozhonghua@qiyi.com>
This commit is contained in:
parent
2b75ff6ce4
commit
017a228f6b
7 changed files with 99 additions and 57 deletions
56
src/lib.rs
56
src/lib.rs
|
|
@ -1,57 +1,5 @@
|
|||
//! # ⬆️ Bump2version
|
||||
//!
|
||||
//! Bump2version is a command-line tool for managing version numbers in your projects.
|
||||
//! Easily update version strings, create commits, and manage version control tags.
|
||||
//!
|
||||
//! ## Features
|
||||
//!
|
||||
//! - **Incremental Versioning:** Bump major, minor, or patch versions with ease.
|
||||
//! - **Configurability:** Use a configuration file or command-line options to customize behavior.
|
||||
//! - **Git Integration:** Create commits and tags in your version control system.
|
||||
//!
|
||||
//! ## Quick Start
|
||||
//!
|
||||
//! Get started with the `bump2version` CLI by following these simple steps:
|
||||
//!
|
||||
//! 1. Install the `bump2version` tool using Cargo:
|
||||
//!
|
||||
//! ```bash
|
||||
//! cargo install bump2version
|
||||
//! ```
|
||||
//!
|
||||
//! 2. Use the following options to manage version numbers and customize the behavior:
|
||||
//!
|
||||
//! ```bash
|
||||
//! bump2version --current-version 1.2.3 --bump patch
|
||||
//! ```
|
||||
//!
|
||||
//! ## Options
|
||||
//!
|
||||
//! | Option | Description |
|
||||
//! |------------------------|-------------------------------------------------------------------|
|
||||
//! | `--config-file` | Config file to read most of the variables from. |
|
||||
//! | `--current-version` | Version that needs to be updated. |
|
||||
//! | `--bump` | Part of the version to be bumped (default: patch). |
|
||||
//! | `--parse` | Regex parsing the version string (default: \d+\.\d+\.\d+). |
|
||||
//! | `--serialize` | How to format what is parsed back to a version (default: {major}.{minor}.{patch}). |
|
||||
//! | `--dry-run` | Don't write any files, just pretend. |
|
||||
//! | `--new-version` | New version that should be in the files. |
|
||||
//! | `--commit` | Create a commit in version control (default: true). |
|
||||
//! | `--tag` | Create a tag in version control. |
|
||||
//! | `--message` | Commit message (default: Bump version: {current_version} → {new_version}). |
|
||||
//! | `file` | Files to change. |
|
||||
//!
|
||||
//! ## GitHub Repository
|
||||
//!
|
||||
//! You can access the source code for this CLI tool on [GitHub](https://github.com/wiseaidev/bump2version).
|
||||
//!
|
||||
//! ## Contributing
|
||||
//!
|
||||
//! Contributions and feedback are welcome! If you'd like to contribute, report an issue, or suggest an enhancement,
|
||||
//! please engage with the project on [GitHub](https://github.com/wiseaidev/bump2version).
|
||||
//! Your contributions help improve this CLI tool for the community.
|
||||
//!
|
||||
//! **Manage your project versions with ease! 🚀**
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
pub mod cli;
|
||||
pub mod utils;
|
||||
|
|
|
|||
|
|
@ -14,14 +14,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let args = Cli::parse();
|
||||
let config_file = args.config_file.clone();
|
||||
let config_content = fs::read_to_string(args.config_file.clone()).unwrap();
|
||||
let config_version = get_current_version_from_config(&config_content).ok_or("")?;
|
||||
let config_version = get_current_version_from_config(&config_content)
|
||||
.ok_or("failed to get current version from config")?;
|
||||
let current_version = args
|
||||
.current_version
|
||||
.clone()
|
||||
.unwrap_or(config_version)
|
||||
.clone();
|
||||
|
||||
let attempted_new_version = attempt_version_bump(args.clone());
|
||||
let attempted_new_version = if let Some(version) = args.new_version {
|
||||
Some(version)
|
||||
} else {
|
||||
attempt_version_bump(args.clone())
|
||||
};
|
||||
|
||||
if attempted_new_version.is_some() {
|
||||
let new_version = attempted_new_version.clone().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue