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
c90bbb43
Commit
c90bbb43
authored
May 04, 2020
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Revert CODEOWNERS validation of Web requests in diff check"
This reverts commit
d193b526
.
parent
9089200d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
28 deletions
+37
-28
changelogs/unreleased/sh-revert-codeowners-check.yml
changelogs/unreleased/sh-revert-codeowners-check.yml
+0
-5
ee/lib/ee/gitlab/checks/diff_check.rb
ee/lib/ee/gitlab/checks/diff_check.rb
+4
-2
ee/spec/lib/gitlab/checks/diff_check_spec.rb
ee/spec/lib/gitlab/checks/diff_check_spec.rb
+33
-21
No files found.
changelogs/unreleased/sh-revert-codeowners-check.yml
deleted
100644 → 0
View file @
9089200d
---
title
:
Revert CODEOWNERS validation of Web requests in diff check
merge_request
:
30936
author
:
type
:
fixed
ee/lib/ee/gitlab/checks/diff_check.rb
View file @
c90bbb43
...
...
@@ -12,7 +12,7 @@ module EE
def
path_validations
validations
=
[
super
].
flatten
if
!
updated_from_web?
&&
project
.
branch_requires_code_owner_approval?
(
branch_name
)
if
project
.
branch_requires_code_owner_approval?
(
branch_name
)
validations
<<
validate_code_owners
end
...
...
@@ -34,11 +34,13 @@ module EE
matched_rules
=
loader
.
entries
.
collect
{
|
e
|
"-
#{
e
.
pattern
}
"
}
code_owner_path
=
project
.
repository
.
code_owners_blob
(
ref:
branch_name
).
path
||
"CODEOWNERS"
"Pushes to protected branches that contain changes to files that
\n
"
\
msg
=
"Pushes to protected branches that contain changes to files that
\n
"
\
"match patterns defined in `
#{
code_owner_path
}
` are disabled for
\n
"
\
"this project. Please submit these changes via a merge request.
\n\n
"
\
"The following pattern(s) from `
#{
code_owner_path
}
` were matched:
\n
"
\
"
#{
matched_rules
.
join
(
'\n'
)
}
\n
"
updated_from_web?
?
msg
.
tr
(
"
\n
"
,
" "
)
:
msg
end
def
validate_path_locks?
...
...
ee/spec/lib/gitlab/checks/diff_check_spec.rb
View file @
c90bbb43
...
...
@@ -88,6 +88,32 @@ describe Gitlab::Checks::DiffCheck do
end
end
context
"and the user is not listed as a code owner"
do
before
do
stub_feature_flags
(
sectional_codeowners:
false
)
end
context
"for a non-web-based request"
do
it_behaves_like
"returns an error message"
it
"returns an error message with newline chars"
do
expect
(
validation_result
).
to
include
(
"
\n
"
)
end
end
context
"for a web-based request"
do
before
do
expect
(
subject
).
to
receive
(
:updated_from_web?
).
and_return
(
true
)
end
it_behaves_like
"returns an error message"
it
"returns an error message with newline chars removed"
do
expect
(
validation_result
).
not_to
include
(
"
\n
"
)
end
end
end
context
"and the user is not listed as a code owner"
do
it_behaves_like
"returns an error message"
end
...
...
@@ -152,9 +178,7 @@ describe Gitlab::Checks::DiffCheck do
end
context
"when the feature is enabled on the project"
do
context
"updated_from_web? == false"
do
before
do
expect
(
subject
).
to
receive
(
:updated_from_web?
).
and_return
(
false
)
expect
(
project
).
to
receive
(
:branch_requires_code_owner_approval?
)
.
once
.
and_return
(
true
)
end
...
...
@@ -166,18 +190,6 @@ describe Gitlab::Checks::DiffCheck do
expect
(
validations
.
any?
{
|
v
|
!
v
.
is_a?
Proc
}).
to
be_falsy
end
end
context
"updated_from_web? == true"
do
before
do
expect
(
subject
).
to
receive
(
:updated_from_web?
).
and_return
(
true
)
expect
(
project
).
not_to
receive
(
:branch_requires_code_owner_approval?
)
end
it
"returns an empty array"
do
expect
(
subject
.
send
(
:path_validations
)).
to
eq
([])
end
end
end
end
context
'file name rules'
do
...
...
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