diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-30 15:38:16 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-06 16:40:31 +0200 |
commit | 235b105c917c16ab14a79ba13280aff4fd9f1cf9 (patch) | |
tree | 27bfe7e1ff2e4caacbdc4450e510164771b66c19 /app/models/push_event.rb | |
parent | 1632ffa6ad16738994122f0e84f331d50f220879 (diff) | |
download | gitlab-ce-235b105c917c16ab14a79ba13280aff4fd9f1cf9.tar.gz |
Finish migration to the new events setupevents-migration-cleanup
This finishes the procedure for migrating events from the old format
into the new format. Code no longer uses the old setup and the database
tables used during the migration process are swapped, with the old table
being dropped.
While the database migration can be reversed this will 1) take a lot of
time as data has to be coped around 2) won't restore data in the
"events.data" column as we have no way of restoring this.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/37241
Diffstat (limited to 'app/models/push_event.rb')
-rw-r--r-- | app/models/push_event.rb | 77 |
1 files changed, 16 insertions, 61 deletions
diff --git a/app/models/push_event.rb b/app/models/push_event.rb index 3f1ff979de6..23ffb0d4ea8 100644 --- a/app/models/push_event.rb +++ b/app/models/push_event.rb @@ -15,15 +15,21 @@ class PushEvent < Event # should ensure the ID points to a valid project. validates :project_id, presence: true - # The "data" field must not be set for push events since it's not used and a - # waste of space. - validates :data, absence: true - # These fields are also not used for push events, thus storing them would be a # waste. validates :target_id, absence: true validates :target_type, absence: true + delegate :branch?, to: :push_event_payload + delegate :tag?, to: :push_event_payload + delegate :commit_from, to: :push_event_payload + delegate :commit_to, to: :push_event_payload + delegate :ref_type, to: :push_event_payload + delegate :commit_title, to: :push_event_payload + + delegate :commit_count, to: :push_event_payload + alias_method :commits_count, :commit_count + def self.sti_name PUSHED end @@ -36,86 +42,35 @@ class PushEvent < Event !!(commit_from && commit_to) end - def tag? - return super unless push_event_payload - - push_event_payload.tag? - end - - def branch? - return super unless push_event_payload - - push_event_payload.branch? - end - def valid_push? - return super unless push_event_payload - push_event_payload.ref.present? end def new_ref? - return super unless push_event_payload - push_event_payload.created? end def rm_ref? - return super unless push_event_payload - push_event_payload.removed? end - def commit_from - return super unless push_event_payload - - push_event_payload.commit_from - end - - def commit_to - return super unless push_event_payload - - push_event_payload.commit_to + def md_ref? + !(rm_ref? || new_ref?) end def ref_name - return super unless push_event_payload - push_event_payload.ref end - def ref_type - return super unless push_event_payload - - push_event_payload.ref_type - end - - def branch_name - return super unless push_event_payload - - ref_name - end - - def tag_name - return super unless push_event_payload - - ref_name - end - - def commit_title - return super unless push_event_payload - - push_event_payload.commit_title - end + alias_method :branch_name, :ref_name + alias_method :tag_name, :ref_name def commit_id commit_to || commit_from end - def commits_count - return super unless push_event_payload - - push_event_payload.commit_count + def last_push_to_non_root? + branch? && project.default_branch != branch_name end def validate_push_action |