Commit 64874193 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Automatically close merge requests that were locker for 1 day

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent b23f71ec
...@@ -225,6 +225,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -225,6 +225,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@allowed_to_merge = allowed_to_merge? @allowed_to_merge = allowed_to_merge?
@show_merge_controls = @merge_request.open? && @commits.any? && @allowed_to_merge @show_merge_controls = @merge_request.open? && @commits.any? && @allowed_to_merge
@source_branch = @merge_request.source_project.repository.find_branch(@merge_request.source_branch).try(:name) @source_branch = @merge_request.source_project.repository.find_branch(@merge_request.source_branch).try(:name)
if @merge_request.locked_long_ago?
@merge_request.unlock_mr
@merge_request.close
end
end end
def allowed_to_merge? def allowed_to_merge?
......
...@@ -346,4 +346,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -346,4 +346,8 @@ class MergeRequest < ActiveRecord::Base
source_project.repository.branch_names source_project.repository.branch_names
end end
end end
def locked_long_ago?
locked_at && locked_at < (Time.now - 1.day)
end
end end
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
- if @merge_request.closed? - if @merge_request.closed?
%h4 %h4
Closed by #{link_to_member(@project, @merge_request.closed_event.author, avatar: false)} Closed
- if @merge_request.closed_event
by #{link_to_member(@project, @merge_request.closed_event.author, avatar: false)}
#{time_ago_with_tooltip(@merge_request.closed_event.created_at)} #{time_ago_with_tooltip(@merge_request.closed_event.created_at)}
%p Changes were not merged into target branch %p Changes were not merged into target branch
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment