Skip to content

Commit

Permalink
fix(deploys): Honor --project in deploys new subcommand (#2160)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
szokeasaurusrex authored Sep 20, 2024
1 parent c433b4c commit 099919a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
Expand All @@ -2369,9 +2369,11 @@ pub struct Deploy {
pub started: Option<DateTime<Utc>>,
#[serde(rename = "dateFinished")]
pub finished: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub projects: Option<Vec<Cow<'d, str>>>,
}

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() {
Expand Down
6 changes: 4 additions & 2 deletions src/commands/deploys/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
env: matches.get_one::<String>("env").unwrap().to_string(),
name: matches.get_one::<String>("name").cloned(),
url: matches.get_one::<String>("url").cloned(),
projects: matches.get_many::<String>("project").map(|x| x.into_iter().map(|x| x.into()).collect()),
..Default::default()
};

Expand All @@ -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!(
Expand Down

0 comments on commit 099919a

Please sign in to comment.