diff options
Diffstat (limited to 'app/services/projects/update_service.rb')
-rw-r--r-- | app/services/projects/update_service.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb index 2d81bbdaa3b..336e887c241 100644 --- a/app/services/projects/update_service.rb +++ b/app/services/projects/update_service.rb @@ -58,11 +58,11 @@ module Projects def validate! unless valid_visibility_level_change?(project, project.visibility_attribute_value(params)) - raise ValidationError, s_('UpdateProject|New visibility level not allowed!') + raise_validation_error(s_('UpdateProject|New visibility level not allowed!')) end if renaming_project_with_container_registry_tags? - raise ValidationError, s_('UpdateProject|Cannot rename project because it contains container registry tags!') + raise_validation_error(s_('UpdateProject|Cannot rename project because it contains container registry tags!')) end validate_default_branch_change @@ -78,16 +78,17 @@ module Projects params[:previous_default_branch] = previous_default_branch if !project.root_ref?(new_default_branch) && has_custom_head_branch? - raise ValidationError, + raise_validation_error( format( s_("UpdateProject|Could not set the default branch. Do you have a branch named 'HEAD' in your repository? (%{linkStart}How do I fix this?%{linkEnd})"), linkStart: ambiguous_head_documentation_link, linkEnd: '</a>' ).html_safe + ) end after_default_branch_change(previous_default_branch) else - raise ValidationError, s_("UpdateProject|Could not set the default branch") + raise_validation_error(s_("UpdateProject|Could not set the default branch")) end end @@ -144,6 +145,10 @@ module Projects AfterRenameService.new(project, path_before: project.path_before_last_save, full_path_before: project.full_path_before_last_save) end + def raise_validation_error(message) + raise ValidationError, message + end + def update_failed! model_errors = project.errors.full_messages.to_sentence error_message = model_errors.presence || s_('UpdateProject|Project could not be updated!') |