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
41538242
Commit
41538242
authored
Apr 23, 2020
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add :sectional_codeowners feature flag
This shouldn't be enabled at all for now.
parent
9f69b063
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
0 deletions
+50
-0
ee/lib/gitlab/code_owners/file.rb
ee/lib/gitlab/code_owners/file.rb
+8
-0
ee/spec/features/projects/merge_requests/user_edits_merge_request_spec.rb
.../projects/merge_requests/user_edits_merge_request_spec.rb
+2
-0
ee/spec/features/projects/view_blob_with_code_owners_spec.rb
ee/spec/features/projects/view_blob_with_code_owners_spec.rb
+1
-0
ee/spec/lib/gitlab/checks/diff_check_spec.rb
ee/spec/lib/gitlab/checks/diff_check_spec.rb
+8
-0
ee/spec/lib/gitlab/code_owners/file_spec.rb
ee/spec/lib/gitlab/code_owners/file_spec.rb
+16
-0
ee/spec/lib/gitlab/code_owners/loader_spec.rb
ee/spec/lib/gitlab/code_owners/loader_spec.rb
+12
-0
ee/spec/lib/gitlab/code_owners_spec.rb
ee/spec/lib/gitlab/code_owners_spec.rb
+3
-0
No files found.
ee/lib/gitlab/code_owners/file.rb
View file @
41538242
...
@@ -40,6 +40,10 @@ module Gitlab
...
@@ -40,6 +40,10 @@ module Gitlab
end
end
def
get_parsed_data
def
get_parsed_data
if
Feature
.
enabled?
(
:sectional_codeowners
,
default_enabled:
false
)
return
get_parsed_sectional_data
end
parsed
=
{}
parsed
=
{}
data
.
lines
.
each
do
|
line
|
data
.
lines
.
each
do
|
line
|
...
@@ -57,6 +61,10 @@ module Gitlab
...
@@ -57,6 +61,10 @@ module Gitlab
parsed
parsed
end
end
def
get_parsed_sectional_data
{}
end
def
normalize_pattern
(
pattern
)
def
normalize_pattern
(
pattern
)
# Remove `\` when escaping `\#`
# Remove `\` when escaping `\#`
pattern
=
pattern
.
sub
(
/\A\\#/
,
'#'
)
pattern
=
pattern
.
sub
(
/\A\\#/
,
'#'
)
...
...
ee/spec/features/projects/merge_requests/user_edits_merge_request_spec.rb
View file @
41538242
...
@@ -32,6 +32,8 @@ describe 'Projects > Merge Requests > User edits a merge request' do
...
@@ -32,6 +32,8 @@ describe 'Projects > Merge Requests > User edits a merge request' do
let
(
:ruby_owner
)
{
create
(
:user
,
username:
'ruby-owner'
)
}
let
(
:ruby_owner
)
{
create
(
:user
,
username:
'ruby-owner'
)
}
before
do
before
do
stub_feature_flags
(
sectional_codeowners:
false
)
project
.
add_developer
(
ruby_owner
)
project
.
add_developer
(
ruby_owner
)
project
.
repository
.
create_file
(
user
,
'ruby.rb'
,
'# a ruby file'
,
project
.
repository
.
create_file
(
user
,
'ruby.rb'
,
'# a ruby file'
,
message:
'Add a ruby file'
,
message:
'Add a ruby file'
,
...
...
ee/spec/features/projects/view_blob_with_code_owners_spec.rb
View file @
41538242
...
@@ -22,6 +22,7 @@ describe 'File blob > Code owners', :js do
...
@@ -22,6 +22,7 @@ describe 'File blob > Code owners', :js do
context
'when the feature is available'
do
context
'when the feature is available'
do
before
do
before
do
stub_licensed_features
(
code_owners:
true
)
stub_licensed_features
(
code_owners:
true
)
stub_feature_flags
(
sectional_codeowners:
false
)
end
end
it
'shows the code owners related to a file'
do
it
'shows the code owners related to a file'
do
...
...
ee/spec/lib/gitlab/checks/diff_check_spec.rb
View file @
41538242
...
@@ -56,6 +56,10 @@ describe Gitlab::Checks::DiffCheck do
...
@@ -56,6 +56,10 @@ describe Gitlab::Checks::DiffCheck do
end
end
context
'and the user is not listed as a codeowner'
do
context
'and the user is not listed as a codeowner'
do
before
do
stub_feature_flags
(
sectional_codeowners:
false
)
end
it
"returns an error message"
do
it
"returns an error message"
do
expect
{
diff_check
.
validate!
}.
to
raise_error
do
|
error
|
expect
{
diff_check
.
validate!
}.
to
raise_error
do
|
error
|
expect
(
error
).
to
be_a
(
Gitlab
::
GitAccess
::
ForbiddenError
)
expect
(
error
).
to
be_a
(
Gitlab
::
GitAccess
::
ForbiddenError
)
...
@@ -81,6 +85,10 @@ describe Gitlab::Checks::DiffCheck do
...
@@ -81,6 +85,10 @@ describe Gitlab::Checks::DiffCheck do
end
end
context
"and the user is not listed as a code owner"
do
context
"and the user is not listed as a code owner"
do
before
do
stub_feature_flags
(
sectional_codeowners:
false
)
end
it
"returns an error message"
do
it
"returns an error message"
do
expect
(
validation_result
).
to
include
(
"Pushes to protected branches"
)
expect
(
validation_result
).
to
include
(
"Pushes to protected branches"
)
end
end
...
...
ee/spec/lib/gitlab/code_owners/file_spec.rb
View file @
41538242
...
@@ -14,6 +14,10 @@ describe Gitlab::CodeOwners::File do
...
@@ -14,6 +14,10 @@ describe Gitlab::CodeOwners::File do
subject
(
:file
)
{
described_class
.
new
(
blob
)
}
subject
(
:file
)
{
described_class
.
new
(
blob
)
}
before
do
stub_feature_flags
(
sectional_codeowners:
false
)
end
describe
'#parsed_data'
do
describe
'#parsed_data'
do
def
owner_line
(
pattern
)
def
owner_line
(
pattern
)
file
.
parsed_data
[
pattern
].
owner_line
file
.
parsed_data
[
pattern
].
owner_line
...
@@ -32,6 +36,18 @@ describe Gitlab::CodeOwners::File do
...
@@ -32,6 +36,18 @@ describe Gitlab::CodeOwners::File do
it
'allows usernames and emails'
do
it
'allows usernames and emails'
do
expect
(
owner_line
(
'/**/LICENSE'
)).
to
include
(
'legal'
,
'janedoe@gitlab.com'
)
expect
(
owner_line
(
'/**/LICENSE'
)).
to
include
(
'legal'
,
'janedoe@gitlab.com'
)
end
end
context
"when feature flag `:sectional_codeowners` is enabled"
do
before
do
stub_feature_flags
(
sectional_codeowners:
true
)
end
it
"passes the call to #get_parsed_sectional_data"
do
expect
(
file
).
to
receive
(
:get_parsed_sectional_data
).
and_return
({})
expect
(
file
.
parsed_data
).
to
be_empty
end
end
end
end
describe
'#empty?'
do
describe
'#empty?'
do
...
...
ee/spec/lib/gitlab/code_owners/loader_spec.rb
View file @
41538242
...
@@ -39,6 +39,10 @@ describe Gitlab::CodeOwners::Loader do
...
@@ -39,6 +39,10 @@ describe Gitlab::CodeOwners::Loader do
let
(
:expected_entry
)
{
Gitlab
::
CodeOwners
::
Entry
.
new
(
'docs/CODEOWNERS'
,
'@owner-1 owner2@gitlab.org @owner-3 @documentation-owner'
)
}
let
(
:expected_entry
)
{
Gitlab
::
CodeOwners
::
Entry
.
new
(
'docs/CODEOWNERS'
,
'@owner-1 owner2@gitlab.org @owner-3 @documentation-owner'
)
}
let
(
:first_entry
)
{
loader
.
entries
.
first
}
let
(
:first_entry
)
{
loader
.
entries
.
first
}
before
do
stub_feature_flags
(
sectional_codeowners:
false
)
end
it
'returns entries for the matched line'
do
it
'returns entries for the matched line'
do
expect
(
loader
.
entries
).
to
contain_exactly
(
expected_entry
)
expect
(
loader
.
entries
).
to
contain_exactly
(
expected_entry
)
end
end
...
@@ -121,6 +125,10 @@ describe Gitlab::CodeOwners::Loader do
...
@@ -121,6 +125,10 @@ describe Gitlab::CodeOwners::Loader do
end
end
describe
'#members'
do
describe
'#members'
do
before
do
stub_feature_flags
(
sectional_codeowners:
false
)
end
it
'returns users mentioned for the passed path'
do
it
'returns users mentioned for the passed path'
do
expect
(
loader
.
members
).
to
contain_exactly
(
owner_1
,
email_owner
,
documentation_owner
)
expect
(
loader
.
members
).
to
contain_exactly
(
owner_1
,
email_owner
,
documentation_owner
)
end
end
...
@@ -143,6 +151,10 @@ describe Gitlab::CodeOwners::Loader do
...
@@ -143,6 +151,10 @@ describe Gitlab::CodeOwners::Loader do
end
end
describe
'#empty_code_owners?'
do
describe
'#empty_code_owners?'
do
before
do
stub_feature_flags
(
sectional_codeowners:
false
)
end
context
'when file does not exist'
do
context
'when file does not exist'
do
let
(
:codeowner_blob
)
{
nil
}
let
(
:codeowner_blob
)
{
nil
}
...
...
ee/spec/lib/gitlab/code_owners_spec.rb
View file @
41538242
...
@@ -26,6 +26,7 @@ describe Gitlab::CodeOwners do
...
@@ -26,6 +26,7 @@ describe Gitlab::CodeOwners do
context
'when the feature is available'
do
context
'when the feature is available'
do
before
do
before
do
stub_licensed_features
(
code_owners:
true
)
stub_licensed_features
(
code_owners:
true
)
stub_feature_flags
(
sectional_codeowners:
false
)
end
end
it
'returns users for a blob'
do
it
'returns users for a blob'
do
...
@@ -59,6 +60,7 @@ describe Gitlab::CodeOwners do
...
@@ -59,6 +60,7 @@ describe Gitlab::CodeOwners do
before
do
before
do
stub_licensed_features
(
code_owners:
true
)
stub_licensed_features
(
code_owners:
true
)
stub_feature_flags
(
sectional_codeowners:
false
)
end
end
it
"return equivalent results"
do
it
"return equivalent results"
do
...
@@ -89,6 +91,7 @@ describe Gitlab::CodeOwners do
...
@@ -89,6 +91,7 @@ describe Gitlab::CodeOwners do
context
'when the feature is available'
do
context
'when the feature is available'
do
before
do
before
do
stub_licensed_features
(
code_owners:
true
)
stub_licensed_features
(
code_owners:
true
)
stub_feature_flags
(
sectional_codeowners:
false
)
end
end
it
'returns owners for merge request'
do
it
'returns owners for merge request'
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