diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-04-19 22:19:16 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-04-19 22:19:16 +0400 |
commit | 1a0082b46b121b2c7bff0211950adc13855d9344 (patch) | |
tree | 3ed2a630458a67e94bedea722a58e7382a2ee0f1 /app | |
parent | 65f0ed4d264e7015ac9259d82913876c6e198a5d (diff) |
hime last push widget if user already has MR created
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 387172b5804..a32e6958823 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -137,13 +137,21 @@ module ApplicationHelper end end + # Define whenever show last push event + # with suggestion to create MR def show_last_push_widget?(event) - event && - event.last_push_to_non_root? && - !event.rm_ref? && - event.project && - event.project.repository && - event.project.merge_requests_enabled + # Skip if event is not about added or modified non-master branch + return false unless event && event.last_push_to_non_root? && !event.rm_ref? + + project = event.project + + # Skip if project repo is empty or MR disabled + return false unless project && !project.empty_repo? && project.merge_requests_enabled + + # Skip if user already created appropriate MR + return false if project.merge_requests.where(source_branch: event.branch_name).opened.any? + + true end def hexdigest(string) |