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
e1ab44be
Commit
e1ab44be
authored
Oct 30, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate the commit using all known email addresses for the user
parent
5e42f026
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
3 deletions
+12
-3
app/models/push_rule.rb
app/models/push_rule.rb
+2
-2
lib/gitlab/checks/change_access.rb
lib/gitlab/checks/change_access.rb
+1
-1
spec/lib/gitlab/checks/change_access_spec.rb
spec/lib/gitlab/checks/change_access_spec.rb
+7
-0
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+2
-0
No files found.
app/models/push_rule.rb
View file @
e1ab44be
...
...
@@ -33,11 +33,11 @@ class PushRule < ActiveRecord::Base
commit
.
has_signature?
end
def
author_allowed?
(
committer_email
,
current_user_email
)
def
committer_allowed?
(
committer
,
current_user
)
return
true
unless
available?
(
:commit_author_check
)
return
true
unless
commit_author_check
c
ommitter_email
.
casecmp
(
current_user_email
)
==
0
c
urrent_user
==
committer
end
def
commit_message_allowed?
(
message
)
...
...
lib/gitlab/checks/change_access.rb
View file @
e1ab44be
...
...
@@ -213,7 +213,7 @@ module Gitlab
return
"Author's email '
#{
commit
.
author_email
}
' does not follow the pattern '
#{
push_rule
.
author_email_regex
}
'"
end
unless
push_rule
.
author_allowed?
(
commit
.
committer_email
,
user_access
.
user
.
email
)
unless
push_rule
.
committer_allowed?
(
commit
.
committer
,
user_access
.
user
)
return
"You can only push your own commits to this repository"
end
...
...
spec/lib/gitlab/checks/change_access_spec.rb
View file @
e1ab44be
...
...
@@ -456,6 +456,13 @@ describe Gitlab::Checks::ChangeAccess do
it
'does not return an error'
do
expect
{
subject
}.
not_to
raise_error
end
it
'allows the commit when they were done with another email that belongs to the current user'
do
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'secondary_email@user.com'
)
user
.
emails
.
create
(
email:
'secondary_email@user.com'
)
expect
{
subject
}.
not_to
raise_error
end
end
context
'with a commit from a different user'
do
...
...
spec/services/merge_requests/merge_service_spec.rb
View file @
e1ab44be
...
...
@@ -352,4 +352,6 @@ describe MergeRequests::MergeService do
end
end
end
context
''
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