Prevent duplicate merge events
This commit is contained in:
parent
3c5954b8c8
commit
b3d648b4e8
2 changed files with 15 additions and 8 deletions
|
@ -177,15 +177,8 @@ class MergeRequest < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def merge!(user_id)
|
||||
self.author_id_of_changes = user_id
|
||||
self.merge
|
||||
|
||||
Event.create(
|
||||
project: self.project,
|
||||
action: Event::MERGED,
|
||||
target_id: self.id,
|
||||
target_type: "MergeRequest",
|
||||
author_id: user_id
|
||||
)
|
||||
end
|
||||
|
||||
def automerge!(current_user)
|
||||
|
|
|
@ -39,4 +39,18 @@ class ActivityObserver < ActiveRecord::Observer
|
|||
author_id: record.author_id_of_changes
|
||||
)
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue