Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1f3c96f0
Commit
1f3c96f0
authored
Oct 14, 2017
by
Rubén Dávila
Committed by
Bob Van Landuyt
Nov 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do some small refacto plus add the changelog entry
parent
19c7851c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
12 deletions
+14
-12
app/helpers/push_rules_helper.rb
app/helpers/push_rules_helper.rb
+2
-2
app/models/push_rule.rb
app/models/push_rule.rb
+4
-1
app/views/shared/push_rules/_form.html.haml
app/views/shared/push_rules/_form.html.haml
+1
-1
changelogs/unreleased/add_commit_author_check_feature.yml
changelogs/unreleased/add_commit_author_check_feature.yml
+5
-0
ee/app/helpers/ee/projects_helper.rb
ee/app/helpers/ee/projects_helper.rb
+2
-8
No files found.
app/helpers/push_rules_helper.rb
View file @
1f3c96f0
...
...
@@ -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
app/models/push_rule.rb
View file @
1f3c96f0
...
...
@@ -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
...
...
app/views/shared/push_rules/_form.html.haml
View file @
1f3c96f0
=
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
...
...
changelogs/unreleased/add_commit_author_check_feature.yml
0 → 100644
View file @
1f3c96f0
---
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
ee/app/helpers/ee/projects_helper.rb
View file @
1f3c96f0
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment