From ebd1ff884824a53149dad6e47ea64d3a6543605f Mon Sep 17 00:00:00 2001 From: ondra Date: Tue, 23 Sep 2025 23:02:47 +0200 Subject: [PATCH] formatting, release --- CHANGELOG.md | 7 +++ Cargo.lock | 65 +++++++++++++++++++++++++++- Cargo.toml | 4 +- changelog/channels/default.json | 7 +++ clpack.toml | 4 ++ src/action_pack.rs | 7 ++- src/assets/config_file_template.toml | 10 +++-- src/config.rs | 3 ++ src/integrations/youtrack.rs | 15 +++++-- src/main.rs | 2 + 10 files changed, 111 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f40ba28..a466841 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.1.0] - 2025-09-23 + +### New features +- Add integration to JetBrains YouTrack (#SW-4712) +- Add command line option `cl status` (#SW-4716) +- Change `cl pack` to show a preview of the rendered changelog before asking for version. + ## [1.0.0] - 2025-09-15 - First stable release, file format version 1 diff --git a/Cargo.lock b/Cargo.lock index 5c22a24..9721e5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,13 +212,14 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "clpack" -version = "1.0.0" +version = "1.1.0" dependencies = [ "anyhow", "chrono", "clap", "colored", "dotenv", + "env_logger", "faccess", "indexmap", "inquire", @@ -362,6 +363,29 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_filter" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -865,6 +889,30 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jiff" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "js-sys" version = "0.3.78" @@ -1110,6 +1158,21 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "potential_utf" version = "0.1.3" diff --git a/Cargo.toml b/Cargo.toml index 219abe1..c76cf24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clpack" -version = "1.0.0" +version = "1.1.0" edition = "2024" authors = ["Ondřej Hruška "] description = "Manage changelog across multiple release channels" @@ -25,5 +25,7 @@ reqwest = { version = "0.12", features = ["rustls-tls", "blocking"] } #, optiona json_dotpath = "1.1.0" dotenv = "0.15.0" +env_logger = "0.11.8" + [dev-dependencies] simple-logging = "2" diff --git a/changelog/channels/default.json b/changelog/channels/default.json index 9bf1c8c..0f6c0b3 100644 --- a/changelog/channels/default.json +++ b/changelog/channels/default.json @@ -4,5 +4,12 @@ "entries": [ "stable release" ] + }, + { + "version": "1.1.0", + "entries": [ + "SW-4712-clpack-youtrack-integration", + "SW-4716-add-cl-status" + ] } ] \ No newline at end of file diff --git a/clpack.toml b/clpack.toml index 320c99b..5a08cd5 100644 --- a/clpack.toml +++ b/clpack.toml @@ -116,3 +116,7 @@ released_state = "Released" # Change a custom version field of the released issues. # Uncomment to enable, change to fit your project version_field = "Available in version" + +# If multiple logical projects are tracked in the same YouTrack project, versions may beed namespacing. +# This prefix is added to versions when creating them in YouTrack +version_prefix = "clpack-" diff --git a/src/action_pack.rs b/src/action_pack.rs index 3ed5a59..33dcb2a 100644 --- a/src/action_pack.rs +++ b/src/action_pack.rs @@ -1,12 +1,11 @@ use crate::AppContext; -use crate::config::{ChannelName, ENV_YOUTRACK_TOKEN, ENV_YOUTRACK_URL}; +use crate::config::ChannelName; use crate::git::{BranchName, get_branch_name}; use crate::integrations::youtrack::{ - YouTrackClient, youtrack_integration_enabled, youtrack_integration_on_release, + youtrack_integration_enabled, youtrack_integration_on_release, }; use crate::store::{Release, Store}; -use crate::utils::empty_to_none::EmptyToNone; -use anyhow::{Context, bail}; +use anyhow::bail; use colored::Colorize; pub fn pack_resolve_and_show_preview( diff --git a/src/assets/config_file_template.toml b/src/assets/config_file_template.toml index 339f549..ae89bf2 100644 --- a/src/assets/config_file_template.toml +++ b/src/assets/config_file_template.toml @@ -78,8 +78,8 @@ branch_version_pattern = '/^rel\/([\d.]+)$/' default = '/^(?:main|master)$/' [integrations.youtrack] -# When creating a release, clpack can mark the included issues -# as "Released" and record the versions into YouTrack. +# When creating a release, clpack can mark the included issues as "Released" and record +# the versions into YouTrack. # # clpack will ask for confirmation before doing this. # @@ -102,7 +102,7 @@ enabled = false # YouTrack server URL. Can be changed locally by setting env var CLPACK_YOUTRACK_URL url = "https://example.youtrack.cloud" -# Channels filter - release on those channels will trigger the YouTrack integration +# Channels filter - release on those channels will trigger the YouTrack integration # (i.e. don't mark as Released if it's only in beta) channels = [ "default" @@ -115,3 +115,7 @@ channels = [ # Change a custom version field of the released issues. # Uncomment to enable, change to fit your project #version_field = "Available in version" + +# If multiple logical projects are tracked in the same YouTrack project, versions may beed namespacing. +# This prefix is added to versions as fetched/created in YouTrack +#version_prefix = "" diff --git a/src/config.rs b/src/config.rs index 77a2226..efe1b69 100644 --- a/src/config.rs +++ b/src/config.rs @@ -145,4 +145,7 @@ pub struct YouTrackIntegrationConfig { /// Name of the version field (Available in version) pub version_field: Option, + + /// Version prefix + pub version_prefix: String, } diff --git a/src/integrations/youtrack.rs b/src/integrations/youtrack.rs index 75332f1..e813700 100644 --- a/src/integrations/youtrack.rs +++ b/src/integrations/youtrack.rs @@ -52,6 +52,9 @@ pub fn youtrack_integration_on_release( let client = YouTrackClient::new(url, &token)?; let mut project_id_opt = None; + let mut set_version_opt = None; + + let prefixed_version = format!("{}{}", ytconf.version_prefix, release.version); let date = chrono::Utc::now(); for entry in release.entries { @@ -77,11 +80,12 @@ pub fn youtrack_integration_on_release( let project_id = project_id_opt.as_ref().unwrap(); // We know it is set now - let mut set_version_opt = None; - if let Some(field) = &ytconf.version_field { + if let Some(field) = &ytconf.version_field + && set_version_opt.is_none() + { let set_version = SetVersion { field_name: field, - version: &release.version, + version: &prefixed_version, }; client.ensure_version_exists_in_project(&project_id, &set_version, Some(date))?; @@ -281,7 +285,7 @@ impl YouTrackClient { } // Got something? - let Some((field_id, bundle_id)) = field_bundle else { + let Some((_field_id, bundle_id)) = field_bundle else { bail!( "YouTrack version field {field_name} not found in the project {project_id}", field_name = version_info.field_name @@ -293,6 +297,7 @@ impl YouTrackClient { #[derive(Deserialize)] struct YTVersion { name: VersionName, + #[allow(unused)] id: String, } @@ -335,6 +340,7 @@ impl YouTrackClient { #[derive(Deserialize, Debug)] #[allow(non_snake_case)] + #[allow(unused)] struct CreateVersionResponse { releaseDate: Option, released: bool, @@ -457,6 +463,7 @@ mod tests { use log::{LevelFilter, debug}; // #[test] // Disabled + #[allow(unused)] fn test_youtrack_communication() { simple_logging::log_to_stderr(LevelFilter::Debug); diff --git a/src/main.rs b/src/main.rs index 0678dff..d96f99c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,6 +39,8 @@ pub struct AppContext { } fn main() { + env_logger::init(); + if let Err(e) = main_try() { eprintln!("{}", format!("{:?}", e).red().bold()); exit(1);