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
5b70ffcf
Commit
5b70ffcf
authored
Jul 30, 2019
by
Pavel Shutsin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add MergeRequestDiff#lines_count convenience method
parent
55320ff6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+6
-0
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+6
-0
spec/models/merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+8
-0
No files found.
app/models/merge_request_diff.rb
View file @
5b70ffcf
...
...
@@ -196,6 +196,12 @@ class MergeRequestDiff < ApplicationRecord
real_size
.
presence
||
raw_diffs
.
size
end
def
lines_count
strong_memoize
(
:lines_count
)
do
diffs
.
diff_files
.
sum
(
&
:line_count
)
end
end
def
raw_diffs
(
options
=
{})
if
options
[
:ignore_whitespace_change
]
@diffs_no_whitespace
||=
compare
.
diffs
(
options
)
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
5b70ffcf
...
...
@@ -235,6 +235,12 @@ MergeRequest::Metrics:
-
latest_build_started_at
-
latest_build_finished_at
-
first_deployed_to_production_at
-
first_comment_at
-
first_commit_at
-
last_commit_at
-
diff_size
-
modified_paths_size
-
commits_count
Ci::Pipeline:
-
id
-
project_id
...
...
spec/models/merge_request_diff_spec.rb
View file @
5b70ffcf
...
...
@@ -484,4 +484,12 @@ describe MergeRequestDiff do
end
end
end
describe
'#lines_count'
do
subject
{
diff_with_commits
}
it
'returns sum of all changed lines count in diff files'
do
expect
(
subject
.
lines_count
).
to
eq
109
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