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
48d06c74
Commit
48d06c74
authored
Apr 08, 2020
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use modified paths inside AuthorityAnalyzer
parent
da6b9e51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
20 deletions
+10
-20
ee/lib/gitlab/authority_analyzer.rb
ee/lib/gitlab/authority_analyzer.rb
+2
-14
ee/spec/lib/gitlab/authority_analyzer_spec.rb
ee/spec/lib/gitlab/authority_analyzer_spec.rb
+8
-6
No files found.
ee/lib/gitlab/authority_analyzer.rb
View file @
48d06c74
...
...
@@ -3,6 +3,7 @@
module
Gitlab
class
AuthorityAnalyzer
COMMITS_TO_CONSIDER
=
25
FILES_TO_CONSIDER
=
100
def
initialize
(
merge_request
,
skip_user
)
@merge_request
=
merge_request
...
...
@@ -30,20 +31,7 @@ module Gitlab
end
def
list_of_involved_files
diffable
=
[
@merge_request
.
compare
,
@merge_request
.
merge_request_diff
].
compact
return
[]
if
diffable
.
empty?
compare_diffs
=
diffable
.
first
.
raw_diffs
return
[]
unless
compare_diffs
.
present?
compare_diffs
.
map
do
|
diff
|
if
diff
.
deleted_file
||
diff
.
renamed_file
diff
.
old_path
else
diff
.
new_path
end
end
@merge_request
.
modified_paths
.
first
(
FILES_TO_CONSIDER
)
end
end
end
ee/spec/lib/gitlab/authority_analyzer_spec.rb
View file @
48d06c74
...
...
@@ -9,7 +9,7 @@ describe Gitlab::AuthorityAnalyzer do
let
(
:user_a
)
{
create
(
:user
)
}
let
(
:user_b
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
target_project:
project
,
source_project:
project
)
}
let
(
:files
)
{
[
double
(
:file
,
deleted_file:
true
,
old_path:
'foo'
)]
}
let
(
:files
)
{
%w(so many files)
}
let
(
:commits
)
do
[
...
...
@@ -23,12 +23,14 @@ describe Gitlab::AuthorityAnalyzer do
let
(
:approvers
)
{
described_class
.
new
(
merge_request
,
author
).
calculate
}
before
do
merge_request
.
compare
=
double
(
:compare
,
raw_diffs:
files
)
allow
(
merge_request
.
target_project
.
repository
).
to
receive
(
:commits
).
and_return
(
commits
)
end
it
'returns contributors in order, without skip_user'
do
stub_const
(
'Gitlab::AuthorityAnalyzer::FILES_TO_CONSIDER'
,
1
)
expect
(
merge_request
).
to
receive
(
:modified_paths
).
and_return
(
files
)
expect
(
merge_request
.
target_project
.
repository
).
to
receive
(
:commits
)
.
with
(
merge_request
.
target_branch
,
path:
[
'so'
],
limit:
Gitlab
::
AuthorityAnalyzer
::
COMMITS_TO_CONSIDER
)
.
and_return
(
commits
)
expect
(
approvers
).
to
contain_exactly
(
user_a
,
user_b
)
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