Commit 1f3c96f0 authored by Rubén Dávila's avatar Rubén Dávila Committed by Bob Van Landuyt

Do some small refacto plus add the changelog entry

parent 19c7851c
......@@ -5,7 +5,6 @@ module PushRulesHelper
annotate_with_update_message(message, push_rule,
enabled_globally: PushRule.global&.reject_unsigned_commits,
enabled_in_project: push_rule.reject_unsigned_commits)
message.join(' ')
end
def commit_author_check_description(push_rule)
......@@ -14,7 +13,6 @@ module PushRulesHelper
annotate_with_update_message(message, push_rule,
enabled_globally: PushRule.global&.commit_author_check,
enabled_in_project: push_rule.commit_author_check)
message.join(' ')
end
private
......@@ -33,5 +31,7 @@ module PushRulesHelper
message << s_("ProjectSettings|Contact an admin to change this setting.") unless current_user.admin?
end
end
message.join(' ')
end
end
......@@ -5,7 +5,10 @@ class PushRule < ActiveRecord::Base
validates :max_file_size, numericality: { greater_than_or_equal_to: 0, only_integer: true }
FILES_BLACKLIST = YAML.load_file(Rails.root.join('lib/gitlab/checks/files_blacklist.yml'))
SETTINGS_WITH_GLOBAL_DEFAULT = %i[reject_unsigned_commits commit_author_check].freeze
SETTINGS_WITH_GLOBAL_DEFAULT = %i[
reject_unsigned_commits
commit_author_check
].freeze
SETTINGS_WITH_GLOBAL_DEFAULT.each do |setting|
define_method(setting) do
......
= render 'shared/push_rules/reject_unsigned_commits_setting', form: f, push_rule: f.object
.form-group
= f.check_box :commit_author_check, class: "pull-left", disabled: !can_change_commit_author_check?(f.object)
= f.check_box :commit_author_check, class: "pull-left", disabled: !can_change_push_rule?(f.object, :commit_author_check)
.prepend-left-20
= f.label :commit_author_check, class: "label-light append-bottom-0" do
Author restriction
......
---
title: Add new push rule to enforce that only the author of a commit can push to the repository
merge_request: 3086
author:
type: added
module EE
module ProjectsHelper
def can_change_reject_unsigned_commits?(push_rule)
def can_change_push_rule?(push_rule, rule)
return true if push_rule.global?
can?(current_user, :change_reject_unsigned_commits, @project)
end
def can_change_commit_author_check?(push_rule)
return true if push_rule.global?
can?(current_user, :change_commit_author_check, @project)
can?(current_user, :"change_#{rule}", @project)
end
end
end
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