Skip to content
Snippets Groups Projects
Commit b3d648b4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Prevent duplicate merge events

parent 3c5954b8
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment