diff options
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 6a8f8c3500f..edbca3b537b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -53,6 +53,11 @@ class Project < ActiveRecord::Base update_column(:last_activity_at, self.created_at) end + after_create :set_last_repository_updated_at + def set_last_repository_updated_at + update_column(:last_repository_updated_at, self.created_at) + end + after_destroy :remove_pages # update visibility_level of forks @@ -1271,6 +1276,9 @@ class Project < ActiveRecord::Base else update_attribute(name, value) end + + rescue ActiveRecord::RecordNotSaved => e + handle_update_attribute_error(e, value) end def pushes_since_gc @@ -1392,4 +1400,16 @@ class Project < ActiveRecord::Base ContainerRepository.build_root_repository(self).has_tags? end + + def handle_update_attribute_error(ex, value) + if ex.message.start_with?('Failed to replace') + if value.respond_to?(:each) + invalid = value.detect(&:invalid?) + + raise ex, ([ex.message] + invalid.errors.full_messages).join(' ') if invalid + end + end + + raise ex + end end |