From 099919a11c4d30e442f3cfbb6fb4a2312e902239 Mon Sep 17 00:00:00 2001 From: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:44:08 +0200 Subject: [PATCH] fix(deploys): Honor `--project` in `deploys new` subcommand (#2160) Previously, we ignored the --project arguments passed to the sentry-cli deploys new command. Regardless of whether any --project was provided, the deploy was created for all projects associated with the given release. Now, we respect the --project argument. If provided, we only create the deploy for the project(s) specified. If omitted, the deploy is created for all projects associated with the release, as previously. Fixes #2156 --- src/api/mod.rs | 6 ++++-- src/commands/deploys/new.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/api/mod.rs b/src/api/mod.rs index dd17a0bdc9..c289844940 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -2360,7 +2360,7 @@ impl fmt::Display for Repo { } #[derive(Serialize, Deserialize, Debug, Default)] -pub struct Deploy { +pub struct Deploy<'d> { #[serde(rename = "environment")] pub env: String, pub name: Option, @@ -2369,9 +2369,11 @@ pub struct Deploy { pub started: Option>, #[serde(rename = "dateFinished")] pub finished: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub projects: Option>>, } -impl Deploy { +impl<'d> Deploy<'d> { /// Returns the name of this deploy, defaulting to `"unnamed"`. pub fn name(&self) -> &str { match self.name.as_deref() { diff --git a/src/commands/deploys/new.rs b/src/commands/deploys/new.rs index 0c19089ea7..af4b57bd1e 100644 --- a/src/commands/deploys/new.rs +++ b/src/commands/deploys/new.rs @@ -71,6 +71,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { env: matches.get_one::("env").unwrap().to_string(), name: matches.get_one::("name").cloned(), url: matches.get_one::("url").cloned(), + projects: matches.get_many::("project").map(|x| x.into_iter().map(|x| x.into()).collect()), ..Default::default() }; @@ -90,8 +91,9 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { } let org = config.get_org(matches)?; - let created_deploy = api - .authenticated()? + let authenticated_api = api.authenticated()?; + + let created_deploy = authenticated_api .create_deploy(&org, &version, &deploy)?; println!(