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
ca0cf5a3
Commit
ca0cf5a3
authored
Dec 30, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show 'too many changes' message for merge request
parent
ec4fe443
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
22 deletions
+64
-22
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+6
-0
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+10
-10
app/views/devise/shared/_signup_box.html.haml
app/views/devise/shared/_signup_box.html.haml
+1
-1
app/views/projects/diffs/_diffs.html.haml
app/views/projects/diffs/_diffs.html.haml
+2
-2
app/views/projects/merge_requests/show/_diffs.html.haml
app/views/projects/merge_requests/show/_diffs.html.haml
+1
-9
changelogs/unreleased/issue_25017.yml
changelogs/unreleased/issue_25017.yml
+4
-0
spec/features/merge_requests/diffs_spec.rb
spec/features/merge_requests/diffs_spec.rb
+14
-0
spec/models/merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+26
-0
No files found.
app/helpers/diff_helper.rb
View file @
ca0cf5a3
...
@@ -165,4 +165,10 @@ module DiffHelper
...
@@ -165,4 +165,10 @@ module DiffHelper
link_to
"
#{
hide_whitespace?
?
'Show'
:
'Hide'
}
whitespace changes"
,
url
,
class:
options
[
:class
]
link_to
"
#{
hide_whitespace?
?
'Show'
:
'Hide'
}
whitespace changes"
,
url
,
class:
options
[
:class
]
end
end
def
render_overflow_warning?
(
diff_files
)
diffs
=
@merge_request_diff
.
presence
||
diff_files
diffs
.
overflow?
end
end
end
app/models/merge_request_diff.rb
View file @
ca0cf5a3
...
@@ -234,28 +234,28 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -234,28 +234,28 @@ class MergeRequestDiff < ActiveRecord::Base
# and save it as array of hashes in st_diffs db field
# and save it as array of hashes in st_diffs db field
def
save_diffs
def
save_diffs
new_attributes
=
{}
new_attributes
=
{}
new_diffs
=
[]
if
commits
.
size
.
zero?
if
commits
.
size
.
zero?
new_attributes
[
:state
]
=
:empty
new_attributes
[
:state
]
=
:empty
else
else
diff_collection
=
compare
.
diffs
(
Commit
.
max_diff_options
)
diff_collection
=
compare
.
diffs
(
Commit
.
max_diff_options
)
new_attributes
[
:real_size
]
=
compare
.
diffs
.
real_size
if
diff_collection
.
overflow?
# Set our state to 'overflow' to make the #empty? and #collected?
# methods (generated by StateMachine) return false.
new_attributes
[
:state
]
=
:overflow
end
new_attributes
[
:real_size
]
=
diff_collection
.
real_size
if
diff_collection
.
any?
if
diff_collection
.
any?
new_diffs
=
dump_diffs
(
diff_collection
)
new_diffs
=
dump_diffs
(
diff_collection
)
new_attributes
[
:state
]
=
:collected
new_attributes
[
:state
]
=
:collected
end
end
new_attributes
[
:st_diffs
]
=
new_diffs
||
[]
# Set our state to 'overflow' to make the #empty? and #collected?
# methods (generated by StateMachine) return false.
#
# This attribution has to come at the end of the method so 'overflow'
# state does not get overridden by 'collected'.
new_attributes
[
:state
]
=
:overflow
if
diff_collection
.
overflow?
end
end
new_attributes
[
:st_diffs
]
=
new_diffs
update_columns_serialized
(
new_attributes
)
update_columns_serialized
(
new_attributes
)
end
end
...
...
app/views/devise/shared/_signup_box.html.haml
View file @
ca0cf5a3
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
.form-group
.form-group
=
f
.
label
:email
=
f
.
label
:email
=
f
.
email_field
:email
,
class:
"form-control middle"
,
required:
true
,
title:
"Please provide a valid email address."
=
f
.
email_field
:email
,
class:
"form-control middle"
,
required:
true
,
title:
"Please provide a valid email address."
%div
.form-group
.form-group
=
f
.
label
:email_confirmation
=
f
.
label
:email_confirmation
=
f
.
email_field
:email_confirmation
,
class:
"form-control middle"
,
required:
true
,
title:
"Please retype the email address."
=
f
.
email_field
:email_confirmation
,
class:
"form-control middle"
,
required:
true
,
title:
"Please retype the email address."
.form-group.append-bottom-20
#password-strength
.form-group.append-bottom-20
#password-strength
...
...
app/views/projects/diffs/_diffs.html.haml
View file @
ca0cf5a3
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
=
parallel_diff_btn
=
parallel_diff_btn
=
render
'projects/diffs/stats'
,
diff_files:
diff_files
=
render
'projects/diffs/stats'
,
diff_files:
diff_files
-
if
diff_files
.
overflow?
-
if
render_overflow_warning?
(
diff_files
)
=
render
'projects/diffs/warning'
,
diff_files:
diff
_file
s
=
render
'projects/diffs/warning'
,
diff_files:
diffs
.files
{
data:
{
can_create_note:
can_create_note
}
}
.files
{
data:
{
can_create_note:
can_create_note
}
}
-
diff_files
.
each_with_index
do
|
diff_file
|
-
diff_files
.
each_with_index
do
|
diff_file
|
...
...
app/views/projects/merge_requests/show/_diffs.html.haml
View file @
ca0cf5a3
-
if
@merge_request_diff
.
collected?
-
if
@merge_request_diff
.
collected?
||
@merge_request_diff
.
overflow?
=
render
'projects/merge_requests/show/versions'
=
render
'projects/merge_requests/show/versions'
=
render
"projects/diffs/diffs"
,
diffs:
@diffs
=
render
"projects/diffs/diffs"
,
diffs:
@diffs
-
elsif
@merge_request_diff
.
empty?
-
elsif
@merge_request_diff
.
empty?
.nothing-here-block
Nothing to merge from
#{
@merge_request
.
source_branch
}
into
#{
@merge_request
.
target_branch
}
.nothing-here-block
Nothing to merge from
#{
@merge_request
.
source_branch
}
into
#{
@merge_request
.
target_branch
}
-
else
.alert.alert-warning
%h4
Changes view for this comparison is extremely large.
%p
You can
=
link_to
"download it"
,
merge_request_path
(
@merge_request
,
format: :diff
),
class:
"vlink"
instead.
changelogs/unreleased/issue_25017.yml
0 → 100644
View file @
ca0cf5a3
---
title
:
Show 'too many changes' message for created merge requests when they are too large
merge_request
:
author
:
spec/features/merge_requests/diffs_spec.rb
View file @
ca0cf5a3
...
@@ -22,4 +22,18 @@ feature 'Diffs URL', js: true, feature: true do
...
@@ -22,4 +22,18 @@ feature 'Diffs URL', js: true, feature: true do
expect
(
page
).
to
have_css
(
'.diffs.tab-pane.active'
)
expect
(
page
).
to
have_css
(
'.diffs.tab-pane.active'
)
end
end
end
end
context
'when merge request has overflow'
do
it
'displays warning'
do
allow_any_instance_of
(
MergeRequestDiff
).
to
receive
(
:overflow?
).
and_return
(
true
)
allow
(
Commit
).
to
receive
(
:max_diff_options
).
and_return
(
max_files:
20
,
max_lines:
20
)
visit
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
)
page
.
within
(
'.alert'
)
do
expect
(
page
).
to
have_text
(
"Too many changes to show. Plain diff Email patch To preserve
performance only 3 of 3+ files are displayed."
)
end
end
end
end
end
spec/models/merge_request_diff_spec.rb
View file @
ca0cf5a3
...
@@ -76,6 +76,32 @@ describe MergeRequestDiff, models: true do
...
@@ -76,6 +76,32 @@ describe MergeRequestDiff, models: true do
end
end
end
end
describe
'#save_diffs'
do
it
'saves collected state'
do
mr_diff
=
create
(
:merge_request
).
merge_request_diff
expect
(
mr_diff
.
collected?
).
to
be_truthy
end
it
'saves overflow state'
do
allow
(
Commit
).
to
receive
(
:max_diff_options
)
.
and_return
(
max_lines:
0
,
max_files:
0
)
mr_diff
=
create
(
:merge_request
).
merge_request_diff
expect
(
mr_diff
.
overflow?
).
to
be_truthy
end
it
'saves empty state'
do
allow_any_instance_of
(
MergeRequestDiff
).
to
receive
(
:commits
)
.
and_return
([])
mr_diff
=
create
(
:merge_request
).
merge_request_diff
expect
(
mr_diff
.
empty?
).
to
be_truthy
end
end
describe
'#commits_sha'
do
describe
'#commits_sha'
do
it
'returns all commits SHA using serialized commits'
do
it
'returns all commits SHA using serialized commits'
do
subject
.
st_commits
=
[
subject
.
st_commits
=
[
...
...
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