Don't update/create projects errors were added
This could be done when a block is passed in EE.
This commit is contained in:
parent
96747556e7
commit
e6568d806d
|
@ -46,6 +46,9 @@ module Projects
|
|||
|
||||
yield(@project) if block_given?
|
||||
|
||||
# If the block added errors, don't try to save the project
|
||||
return @project if @project.errors.any?
|
||||
|
||||
@project.creator = current_user
|
||||
|
||||
if forked_from_project_id
|
||||
|
|
|
@ -19,6 +19,9 @@ module Projects
|
|||
|
||||
yield if block_given?
|
||||
|
||||
# If the block added errors, don't try to save the project
|
||||
return validation_failed! if project.errors.any?
|
||||
|
||||
if project.update_attributes(params.except(:default_branch))
|
||||
if project.previous_changes.include?('path')
|
||||
project.rename_repo
|
||||
|
@ -30,10 +33,7 @@ module Projects
|
|||
|
||||
success
|
||||
else
|
||||
model_errors = project.errors.full_messages.to_sentence
|
||||
error_message = model_errors.presence || 'Project could not be updated!'
|
||||
|
||||
error(error_message)
|
||||
validation_failed!
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -45,6 +45,13 @@ module Projects
|
|||
|
||||
private
|
||||
|
||||
def validation_failed!
|
||||
model_errors = project.errors.full_messages.to_sentence
|
||||
error_message = model_errors.presence || 'Project could not be updated!'
|
||||
|
||||
error(error_message)
|
||||
end
|
||||
|
||||
def renaming_project_with_container_registry_tags?
|
||||
new_path = params[:path]
|
||||
|
||||
|
|
Loading…
Reference in New Issue