Commit e009e9c2 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Rename commit_author to commit_committer

parent e1ab44be
...@@ -32,8 +32,8 @@ class Admin::PushRulesController < Admin::ApplicationController ...@@ -32,8 +32,8 @@ class Admin::PushRulesController < Admin::ApplicationController
allowed_fields << :reject_unsigned_commits allowed_fields << :reject_unsigned_commits
end end
if @push_rule.available?(:commit_author_check) if @push_rule.available?(:commit_committer_check)
allowed_fields << :commit_author_check allowed_fields << :commit_committer_check
end end
params.require(:push_rule).permit(allowed_fields) params.require(:push_rule).permit(allowed_fields)
......
...@@ -33,8 +33,8 @@ class Projects::PushRulesController < Projects::ApplicationController ...@@ -33,8 +33,8 @@ class Projects::PushRulesController < Projects::ApplicationController
allowed_fields << :reject_unsigned_commits allowed_fields << :reject_unsigned_commits
end end
if can?(current_user, :change_commit_author_check, project) if can?(current_user, :change_commit_committer_check, project)
allowed_fields << :commit_author_check allowed_fields << :commit_committer_check
end end
params.require(:push_rule).permit(allowed_fields) params.require(:push_rule).permit(allowed_fields)
......
...@@ -5,10 +5,10 @@ module PushRulesHelper ...@@ -5,10 +5,10 @@ module PushRulesHelper
push_rule_update_description(message, push_rule, :reject_unsigned_commits) push_rule_update_description(message, push_rule, :reject_unsigned_commits)
end end
def commit_author_check_description(push_rule) def commit_committer_check_description(push_rule)
message = [s_("ProjectSettings|Only the author of a commit can push changes to this repository.")] message = [s_("ProjectSettings|Only the committer of a commit can push changes to this repository.")]
push_rule_update_description(message, push_rule, :commit_author_check) push_rule_update_description(message, push_rule, :commit_committer_check)
end end
private private
......
...@@ -48,7 +48,7 @@ class License < ActiveRecord::Base ...@@ -48,7 +48,7 @@ class License < ActiveRecord::Base
service_desk service_desk
variable_environment_scope variable_environment_scope
reject_unsigned_commits reject_unsigned_commits
commit_author_check commit_committer_check
].freeze ].freeze
EEU_FEATURES = EEP_FEATURES EEU_FEATURES = EEP_FEATURES
......
...@@ -7,7 +7,7 @@ class PushRule < ActiveRecord::Base ...@@ -7,7 +7,7 @@ class PushRule < ActiveRecord::Base
FILES_BLACKLIST = YAML.load_file(Rails.root.join('lib/gitlab/checks/files_blacklist.yml')) FILES_BLACKLIST = YAML.load_file(Rails.root.join('lib/gitlab/checks/files_blacklist.yml'))
SETTINGS_WITH_GLOBAL_DEFAULT = %i[ SETTINGS_WITH_GLOBAL_DEFAULT = %i[
reject_unsigned_commits reject_unsigned_commits
commit_author_check commit_committer_check
].freeze ].freeze
def self.global def self.global
...@@ -19,7 +19,7 @@ class PushRule < ActiveRecord::Base ...@@ -19,7 +19,7 @@ class PushRule < ActiveRecord::Base
branch_name_regex.present? || branch_name_regex.present? ||
author_email_regex.present? || author_email_regex.present? ||
reject_unsigned_commits || reject_unsigned_commits ||
commit_author_check || commit_committer_check ||
member_check || member_check ||
file_name_regex.present? || file_name_regex.present? ||
max_file_size > 0 || max_file_size > 0 ||
...@@ -34,8 +34,8 @@ class PushRule < ActiveRecord::Base ...@@ -34,8 +34,8 @@ class PushRule < ActiveRecord::Base
end end
def committer_allowed?(committer, current_user) def committer_allowed?(committer, current_user)
return true unless available?(:commit_author_check) return true unless available?(:commit_committer_check)
return true unless commit_author_check return true unless commit_committer_check
current_user == committer current_user == committer
end end
...@@ -81,13 +81,13 @@ class PushRule < ActiveRecord::Base ...@@ -81,13 +81,13 @@ class PushRule < ActiveRecord::Base
write_setting_with_global_default(:reject_unsigned_commits, value) write_setting_with_global_default(:reject_unsigned_commits, value)
end end
def commit_author_check def commit_committer_check
read_setting_with_global_default(:commit_author_check) read_setting_with_global_default(:commit_committer_check)
end end
alias_method :commit_author_check?, :commit_author_check alias_method :commit_committer_check?, :commit_committer_check
def commit_author_check=(value) def commit_committer_check=(value)
write_setting_with_global_default(:commit_author_check, value) write_setting_with_global_default(:commit_committer_check, value)
end end
private private
......
- return unless push_rule.available?(:commit_author_check) - return unless push_rule.available?(:commit_committer_check)
- form = local_assigns.fetch(:form) - form = local_assigns.fetch(:form)
- push_rule = local_assigns.fetch(:push_rule) - push_rule = local_assigns.fetch(:push_rule)
.form-group .form-group
= form.check_box :commit_author_check, class: "pull-left", disabled: !can_change_push_rule?(form.object, :commit_author_check) = form.check_box :commit_committer_check, class: "pull-left", disabled: !can_change_push_rule?(form.object, :commit_committer_check)
.prepend-left-20 .prepend-left-20
= form.label :commit_author_check, class: "label-light append-bottom-0" do = form.label :commit_committer_check, class: "label-light append-bottom-0" do
Author restriction Author restriction
%p.light.append-bottom-0 %p.light.append-bottom-0
= commit_author_check_description(push_rule) = commit_committer_check_description(push_rule)
= render 'shared/push_rules/commit_author_check_setting', form: f, push_rule: f.object = render 'shared/push_rules/commit_committer_check_setting', form: f, push_rule: f.object
= render 'shared/push_rules/reject_unsigned_commits_setting', form: f, push_rule: f.object = render 'shared/push_rules/reject_unsigned_commits_setting', form: f, push_rule: f.object
......
...@@ -63,7 +63,7 @@ The following options are available. ...@@ -63,7 +63,7 @@ The following options are available.
| --------- | :------------: | ----------- | | --------- | :------------: | ----------- |
| Removal of tags with `git push` | 7.10 | Forbid users to remove git tags with `git push`. Tags will still be able to be deleted through the web UI. | | Removal of tags with `git push` | 7.10 | Forbid users to remove git tags with `git push`. Tags will still be able to be deleted through the web UI. |
| Check whether author is a GitLab user | 7.10 | Restrict commits by author (email) to existing GitLab users. | | Check whether author is a GitLab user | 7.10 | Restrict commits by author (email) to existing GitLab users. |
| Check whether author is the current authenticated user | 10.2 | GitLab will reject any commit that does not belongs to the current authenticated user | | Check whether committer is the current authenticated user | 10.2 | GitLab will reject any commit that was not committed by the current authenticated user |
| Check whether commit is signed through GPG | 10.1 | Reject commit when it is not signed through GPG. Read [signing commits with GPG][signing-commits]. | | Check whether commit is signed through GPG | 10.1 | Reject commit when it is not signed through GPG. Read [signing commits with GPG][signing-commits]. |
| Prevent committing secrets to Git | 8.12 | GitLab will reject any files that are likely to contain secrets. Read [what files are forbidden](#prevent-pushing-secrets-to-the-repository). | | Prevent committing secrets to Git | 8.12 | GitLab will reject any files that are likely to contain secrets. Read [what files are forbidden](#prevent-pushing-secrets-to-the-repository). |
| Restrict by commit message | 7.10 | Only commit messages that match this Ruby regular expression are allowed to be pushed. Leave empty to allow any commit message. | | Restrict by commit message | 7.10 | Only commit messages that match this Ruby regular expression are allowed to be pushed. Leave empty to allow any commit message. |
......
...@@ -21,8 +21,8 @@ module EE ...@@ -21,8 +21,8 @@ module EE
end end
with_scope :global with_scope :global
condition(:commit_author_check_disabled_globally) do condition(:commit_committer_check_disabled_globally) do
!PushRule.global&.commit_author_check !PushRule.global&.commit_committer_check
end end
with_scope :global with_scope :global
...@@ -90,7 +90,7 @@ module EE ...@@ -90,7 +90,7 @@ module EE
rule { admin | (reject_unsigned_commits_disabled_globally & can?(:master_access)) }.enable :change_reject_unsigned_commits rule { admin | (reject_unsigned_commits_disabled_globally & can?(:master_access)) }.enable :change_reject_unsigned_commits
rule { admin | (commit_author_check_disabled_globally & can?(:master_access)) }.enable :change_commit_author_check rule { admin | (commit_committer_check_disabled_globally & can?(:master_access)) }.enable :change_commit_committer_check
end end
end end
end end
...@@ -9,7 +9,7 @@ describe "Admin::PushRules" do ...@@ -9,7 +9,7 @@ describe "Admin::PushRules" do
push_rules_with_titles = { push_rules_with_titles = {
reject_unsigned_commits: 'Reject unsigned commits', reject_unsigned_commits: 'Reject unsigned commits',
commit_author_check: 'Author restriction' commit_committer_check: 'Author restriction'
} }
push_rules_with_titles.each do |rule_attr, title| push_rules_with_titles.each do |rule_attr, title|
......
...@@ -12,7 +12,7 @@ feature 'Projects > Push Rules', :js do ...@@ -12,7 +12,7 @@ feature 'Projects > Push Rules', :js do
push_rules_with_titles = { push_rules_with_titles = {
reject_unsigned_commits: 'Reject unsigned commits', reject_unsigned_commits: 'Reject unsigned commits',
commit_author_check: 'Author restriction' commit_committer_check: 'Author restriction'
} }
push_rules_with_titles.each do |rule_attr, title| push_rules_with_titles.each do |rule_attr, title|
......
...@@ -7,7 +7,7 @@ describe PushRulesHelper do ...@@ -7,7 +7,7 @@ describe PushRulesHelper do
let(:project_owner) { push_rule.project.owner } let(:project_owner) { push_rule.project.owner }
let(:possible_help_texts) do let(:possible_help_texts) do
{ {
commit_author_check_base_help: /Only the author of a commit can push changes to this repository/, commit_committer_check_base_help: /Only the committer of a commit can push changes to this repository/,
reject_unsigned_commits_base_help: /Only signed commits can be pushed to this repository/, reject_unsigned_commits_base_help: /Only signed commits can be pushed to this repository/,
default_admin_help: /This setting will be applied to all projects unless overridden by an admin/, default_admin_help: /This setting will be applied to all projects unless overridden by an admin/,
setting_can_be_overridden: /This setting is applied on the server level and can be overridden by an admin/, setting_can_be_overridden: /This setting is applied on the server level and can be overridden by an admin/,
......
...@@ -443,10 +443,10 @@ describe Gitlab::Checks::ChangeAccess do ...@@ -443,10 +443,10 @@ describe Gitlab::Checks::ChangeAccess do
context 'Check commit author rules' do context 'Check commit author rules' do
before do before do
stub_licensed_features(commit_author_check: true) stub_licensed_features(commit_committer_check: true)
end end
let(:push_rule) { create(:push_rule, commit_author_check: true) } let(:push_rule) { create(:push_rule, commit_committer_check: true) }
context 'with a commit from the authenticated user' do context 'with a commit from the authenticated user' do
before do before do
......
...@@ -24,7 +24,7 @@ describe PushRule do ...@@ -24,7 +24,7 @@ describe PushRule do
author_email_regex: 'regex', author_email_regex: 'regex',
file_name_regex: 'regex', file_name_regex: 'regex',
reject_unsigned_commits: true, reject_unsigned_commits: true,
commit_author_check: true, commit_committer_check: true,
member_check: true, member_check: true,
prevent_secrets: true, prevent_secrets: true,
max_file_size: 1 max_file_size: 1
......
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