Prevent duplicate merge events

This commit is contained in:
Dmitriy Zaporozhets 2013-02-27 17:48:51 +02:00
parent 3c5954b8c8
commit b3d648b4e8
2 changed files with 15 additions and 8 deletions

View file

@ -177,15 +177,8 @@ class MergeRequest < ActiveRecord::Base
end end
def merge!(user_id) def merge!(user_id)
self.author_id_of_changes = user_id
self.merge self.merge
Event.create(
project: self.project,
action: Event::MERGED,
target_id: self.id,
target_type: "MergeRequest",
author_id: user_id
)
end end
def automerge!(current_user) def automerge!(current_user)

View file

@ -39,4 +39,18 @@ class ActivityObserver < ActiveRecord::Observer
author_id: record.author_id_of_changes author_id: record.author_id_of_changes
) )
end end
def after_merge(record, transition)
# Since MR can be merged via sidekiq
# to prevent event duplication do this check
return true if record.merge_event
Event.create(
project: record.project,
target_id: record.id,
target_type: record.class.name,
action: Event::MERGED,
author_id: record.author_id_of_changes
)
end
end end