diff --git a/docs/reference.md b/docs/reference.md index 5854357a9..4dabd700e 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -52,12 +52,12 @@ Configuration is read from the following (in precedence order) | `sign-tag` | `--sign-tag` | bool | Use GPG to sign git tag generated by cargo-release. | | `push-remote` | `--push-remote` | string | Default git remote to push | | `registry` | `--registry` | string | Cargo registry name to publish to (default uses Rust's default, which goes to `crates.io`) | -| `disable-release` | `--exclude` | bool | Skip the entire release process (usually for internal crates in a workspace) | -| `disable-push` | `--no-push` | bool | Don't do git push | +| `release` | `--exclude` | bool | Skip the entire release process (usually for internal crates in a workspace) | +| `push` | `--no-push` | bool | Don't do git push | | `push-options` | \- | list of strings | Flags to send to the server when doing a `git push` | -| `disable-tag` | `--no-tag` | bool | Don't do git tag | -| `disable-publish` | `--no-publish` | bool | Don't do cargo publish right now, see [manifest `publish` field](https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish--field-optional) to permanently disable publish. | -| `no-verify` | `--no-verify` | bool | Don't verify the contents by building them | +| `tag` | `--no-tag` | bool | Don't do git tag | +| `publish` | `--no-publish` | bool | Don't do cargo publish right now, see [manifest `publish` field](https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish--field-optional) to permanently disable publish. | +| `verify` | `--no-verify` | bool | Don't verify the contents by building them | | `shared-version` | \- | bool | Ensure all crates with `shared_version` are the same version | | `consolidate-commits` | \- | bool | When releasing a workspace, use a single commit for the pre-release version bump and a single commit for the post-release version bump. | | `consolidate-pushes` | \- | bool | When releasing a workspace, use do a single push across all crates in a workspace. | @@ -67,7 +67,7 @@ Configuration is read from the following (in precedence order) | `tag-prefix` | `--tag-prefix` | string | Prefix of git tag, note that this will override default prefix based on crate name. | | `tag-name` | `--tag-name` | string | The name of the git tag. The placeholder `{{prefix}}` (the tag prefix) is supported in addition to the global placeholders mentioned below. | | `dev-version-ext` | `--dev-version-ext` | string | Pre-release extension to use on the next development version. | -| `no-dev-version` | `--no-dev-version` | bool | Disable version bump after release. | +| `dev-version` | `--no-dev-version` | bool | Disable version bump after release. | | `pre-release-replacements` | \- | array of tables (see below) | Specify files that cargo-release will search and replace with new version for the release commit | | `post-release-replacements` | \- | array of tables (see below) | Specify files that cargo-release will search and replace with new version for the post-release commit (the one starting development) | | `pre-release-hook` | \- | list of arguments | Provide a command to run before `cargo-release` commits version change. If the return code of hook command is greater than 0, the release process will be aborted. | diff --git a/src/args.rs b/src/args.rs index d768b9671..7c4f5df33 100644 --- a/src/args.rs +++ b/src/args.rs @@ -165,14 +165,14 @@ impl ConfigArgs { sign_tag: resolve_bool_arg(self.sign_tag, self.no_sign_tag).or_else(|| self.sign()), push_remote: self.push_remote.clone(), registry: self.registry.clone(), - disable_publish: resolve_bool_arg(self.no_publish, self.publish), - no_verify: resolve_bool_arg(self.no_verify, self.verify), - disable_push: resolve_bool_arg(self.no_push, self.push), + publish: resolve_bool_arg(self.publish, self.no_publish), + verify: resolve_bool_arg(self.verify, self.no_verify), + push: resolve_bool_arg(self.push, self.no_push), dev_version_ext: self.dev_version_ext.clone(), - no_dev_version: resolve_bool_arg(self.no_dev_version, self.dev_version), + dev_version: resolve_bool_arg(self.dev_version, self.no_dev_version), tag_prefix: self.tag_prefix.clone(), tag_name: self.tag_name.clone(), - disable_tag: resolve_bool_arg(self.no_tag, self.tag), + tag: resolve_bool_arg(self.tag, self.no_tag), enable_features: (!self.features.is_empty()).then(|| self.features.clone()), enable_all_features: self.all_features.then(|| true), dependent_version: self.dependent_version, diff --git a/src/config.rs b/src/config.rs index 5348ad283..12b1ef060 100644 --- a/src/config.rs +++ b/src/config.rs @@ -14,12 +14,17 @@ pub struct Config { pub sign_tag: Option, pub push_remote: Option, pub registry: Option, + pub release: Option, pub disable_release: Option, + pub publish: Option, pub disable_publish: Option, + pub verify: Option, pub no_verify: Option, + pub push: Option, pub disable_push: Option, pub push_options: Option>, pub dev_version_ext: Option, + pub dev_version: Option, pub no_dev_version: Option, pub shared_version: Option, pub consolidate_commits: Option, @@ -32,6 +37,7 @@ pub struct Config { pub tag_message: Option, pub tag_prefix: Option, pub tag_name: Option, + pub tag: Option, pub disable_tag: Option, pub enable_features: Option>, pub enable_all_features: Option, @@ -55,17 +61,21 @@ impl Config { if let Some(registry) = source.registry.as_deref() { self.registry = Some(registry.to_owned()); } - if let Some(disable_release) = source.disable_release { - self.disable_release = Some(disable_release); + if let Some(release) = resolve_bool_arg(source.release, source.disable_release) { + self.release = Some(release); + self.disable_release = None; } - if let Some(disable_publish) = source.disable_publish { - self.disable_publish = Some(disable_publish); + if let Some(publish) = resolve_bool_arg(source.publish, source.disable_publish) { + self.publish = Some(publish); + self.disable_publish = None; } - if let Some(no_verify) = source.no_verify { - self.no_verify = Some(no_verify); + if let Some(verify) = resolve_bool_arg(source.verify, source.no_verify) { + self.verify = Some(verify); + self.no_verify = None; } - if let Some(disable_push) = source.disable_push { - self.disable_push = Some(disable_push); + if let Some(push) = resolve_bool_arg(source.push, source.disable_push) { + self.push = Some(push); + self.disable_push = None; } if let Some(push_options) = source.push_options.as_deref() { self.push_options = Some(push_options.to_owned()); @@ -73,8 +83,9 @@ impl Config { if let Some(dev_version_ext) = source.dev_version_ext.as_deref() { self.dev_version_ext = Some(dev_version_ext.to_owned()); } - if let Some(no_dev_version) = source.no_dev_version { - self.no_dev_version = Some(no_dev_version); + if let Some(dev_version) = resolve_bool_arg(source.dev_version, source.no_dev_version) { + self.dev_version = Some(dev_version); + self.no_dev_version = None; } if let Some(shared_version) = source.shared_version { self.shared_version = Some(shared_version); @@ -109,8 +120,9 @@ impl Config { if let Some(tag_name) = source.tag_name.as_deref() { self.tag_name = Some(tag_name.to_owned()); } - if let Some(disable_tag) = source.disable_tag { - self.disable_tag = Some(disable_tag); + if let Some(tag) = resolve_bool_arg(source.tag, source.disable_tag) { + self.tag = Some(tag); + self.disable_tag = None; } if let Some(enable_features) = source.enable_features.as_deref() { self.enable_features = Some(enable_features.to_owned()); @@ -147,19 +159,19 @@ impl Config { } pub fn release(&self) -> bool { - !self.disable_release.unwrap_or(false) + resolve_bool_arg(self.release, self.disable_release).unwrap_or(true) } pub fn publish(&self) -> bool { - !self.disable_publish.unwrap_or(false) + resolve_bool_arg(self.publish, self.disable_publish).unwrap_or(true) } pub fn verify(&self) -> bool { - !self.no_verify.unwrap_or(false) + resolve_bool_arg(self.verify, self.no_verify).unwrap_or(true) } pub fn push(&self) -> bool { - !self.disable_push.unwrap_or(false) + resolve_bool_arg(self.publish, self.disable_publish).unwrap_or(true) } pub fn push_options(&self) -> &[String] { @@ -174,7 +186,7 @@ impl Config { } pub fn dev_version(&self) -> bool { - !self.no_dev_version.unwrap_or(false) + resolve_bool_arg(self.dev_version, self.no_dev_version).unwrap_or(true) } pub fn shared_version(&self) -> bool { @@ -237,7 +249,7 @@ impl Config { } pub fn tag(&self) -> bool { - !self.disable_tag.unwrap_or(false) + resolve_bool_arg(self.tag, self.disable_tag).unwrap_or(true) } pub fn enable_features(&self) -> &[String] { @@ -495,6 +507,18 @@ pub fn resolve_config(workspace_root: &Path, manifest_path: &Path) -> Result, no: Option) -> Option { + match (yes, no) { + (Some(_), Some(_)) => panic!("`disable_` flags are deprecated and can't be set at the same time with their positive versions"), + (Some(yes), None) => Some(yes), + (None, Some(no)) => { + log::warn!("Negative config values are deprecated (`no_`, `disable_`)"); + Some(!no) + }, + (None, None) => None, + } +} + #[cfg(test)] mod test { use super::*;