Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controllers/version/metadata: Simplify validate_yank_update() fn #9558

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/controllers/version/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,18 @@ pub async fn update(
}

fn validate_yank_update(update_data: &VersionUpdate, version: &Version) -> AppResult<()> {
match (update_data.yanked, &update_data.yank_message) {
(Some(false), Some(_)) => {
if update_data.yank_message.is_some() {
if matches!(update_data.yanked, Some(false)) {
return Err(bad_request("Cannot set yank message when unyanking"));
}
(None, Some(_)) => {
if !version.yanked {
return Err(bad_request(
"Cannot update yank message for a version that is not yanked",
));
}

if update_data.yanked.is_none() && !version.yanked {
return Err(bad_request(
"Cannot update yank message for a version that is not yanked",
));
}
_ => {}
}

Ok(())
}

Expand Down