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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
04cf618b
Commit
04cf618b
authored
May 31, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change no_limits to limits
parent
ce869e39
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
20 deletions
+20
-20
lib/api/commits.rb
lib/api/commits.rb
+1
-1
lib/api/entities.rb
lib/api/entities.rb
+3
-3
lib/api/v3/commits.rb
lib/api/v3/commits.rb
+1
-1
lib/api/v3/entities.rb
lib/api/v3/entities.rb
+1
-1
lib/gitlab/git/diff.rb
lib/gitlab/git/diff.rb
+1
-1
lib/gitlab/git/diff_collection.rb
lib/gitlab/git/diff_collection.rb
+4
-4
spec/lib/gitlab/git/diff_collection_spec.rb
spec/lib/gitlab/git/diff_collection_spec.rb
+9
-9
No files found.
lib/api/commits.rb
View file @
04cf618b
...
@@ -176,7 +176,7 @@ module API
...
@@ -176,7 +176,7 @@ module API
}
}
if
params
[
:path
]
if
params
[
:path
]
commit
.
raw_diffs
(
no_limits:
tru
e
).
each
do
|
diff
|
commit
.
raw_diffs
(
limits:
fals
e
).
each
do
|
diff
|
next
unless
diff
.
new_path
==
params
[
:path
]
next
unless
diff
.
new_path
==
params
[
:path
]
lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff
.
diff
.
each_line
)
lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff
.
diff
.
each_line
)
...
...
lib/api/entities.rb
View file @
04cf618b
...
@@ -331,7 +331,7 @@ module API
...
@@ -331,7 +331,7 @@ module API
class
MergeRequestChanges
<
MergeRequest
class
MergeRequestChanges
<
MergeRequest
expose
:diffs
,
as: :changes
,
using:
Entities
::
RepoDiff
do
|
compare
,
_
|
expose
:diffs
,
as: :changes
,
using:
Entities
::
RepoDiff
do
|
compare
,
_
|
compare
.
raw_diffs
(
no_limits:
tru
e
).
to_a
compare
.
raw_diffs
(
limits:
fals
e
).
to_a
end
end
end
end
...
@@ -344,7 +344,7 @@ module API
...
@@ -344,7 +344,7 @@ module API
expose
:commits
,
using:
Entities
::
RepoCommit
expose
:commits
,
using:
Entities
::
RepoCommit
expose
:diffs
,
using:
Entities
::
RepoDiff
do
|
compare
,
_
|
expose
:diffs
,
using:
Entities
::
RepoDiff
do
|
compare
,
_
|
compare
.
raw_diffs
(
no_limits:
tru
e
).
to_a
compare
.
raw_diffs
(
limits:
fals
e
).
to_a
end
end
end
end
...
@@ -548,7 +548,7 @@ module API
...
@@ -548,7 +548,7 @@ module API
end
end
expose
:diffs
,
using:
Entities
::
RepoDiff
do
|
compare
,
options
|
expose
:diffs
,
using:
Entities
::
RepoDiff
do
|
compare
,
options
|
compare
.
diffs
(
no_limits:
tru
e
).
to_a
compare
.
diffs
(
limits:
fals
e
).
to_a
end
end
expose
:compare_timeout
do
|
compare
,
options
|
expose
:compare_timeout
do
|
compare
,
options
|
...
...
lib/api/v3/commits.rb
View file @
04cf618b
...
@@ -167,7 +167,7 @@ module API
...
@@ -167,7 +167,7 @@ module API
}
}
if
params
[
:path
]
if
params
[
:path
]
commit
.
raw_diffs
(
no_limits:
tru
e
).
each
do
|
diff
|
commit
.
raw_diffs
(
limits:
fals
e
).
each
do
|
diff
|
next
unless
diff
.
new_path
==
params
[
:path
]
next
unless
diff
.
new_path
==
params
[
:path
]
lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff
.
diff
.
each_line
)
lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff
.
diff
.
each_line
)
...
...
lib/api/v3/entities.rb
View file @
04cf618b
...
@@ -226,7 +226,7 @@ module API
...
@@ -226,7 +226,7 @@ module API
class
MergeRequestChanges
<
MergeRequest
class
MergeRequestChanges
<
MergeRequest
expose
:diffs
,
as: :changes
,
using:
::
API
::
Entities
::
RepoDiff
do
|
compare
,
_
|
expose
:diffs
,
as: :changes
,
using:
::
API
::
Entities
::
RepoDiff
do
|
compare
,
_
|
compare
.
raw_diffs
(
no_limits:
tru
e
).
to_a
compare
.
raw_diffs
(
limits:
fals
e
).
to_a
end
end
end
end
...
...
lib/gitlab/git/diff.rb
View file @
04cf618b
...
@@ -155,7 +155,7 @@ module Gitlab
...
@@ -155,7 +155,7 @@ module Gitlab
:include_untracked_content
,
:skip_binary_check
,
:include_untracked_content
,
:skip_binary_check
,
:include_typechange
,
:include_typechange_trees
,
:include_typechange
,
:include_typechange_trees
,
:ignore_filemode
,
:recurse_ignored_dirs
,
:paths
,
:ignore_filemode
,
:recurse_ignored_dirs
,
:paths
,
:max_files
,
:max_lines
,
:
no_
limits
,
:expanded
]
:max_files
,
:max_lines
,
:limits
,
:expanded
]
if
default_options
if
default_options
actual_defaults
=
default_options
.
dup
actual_defaults
=
default_options
.
dup
...
...
lib/gitlab/git/diff_collection.rb
View file @
04cf618b
...
@@ -13,7 +13,7 @@ module Gitlab
...
@@ -13,7 +13,7 @@ module Gitlab
@safe_max_files
=
[
@max_files
,
DEFAULT_LIMITS
[
:max_files
]].
min
@safe_max_files
=
[
@max_files
,
DEFAULT_LIMITS
[
:max_files
]].
min
@safe_max_lines
=
[
@max_lines
,
DEFAULT_LIMITS
[
:max_lines
]].
min
@safe_max_lines
=
[
@max_lines
,
DEFAULT_LIMITS
[
:max_lines
]].
min
@safe_max_bytes
=
@safe_max_files
*
5
.
kilobytes
# Average 5 KB per file
@safe_max_bytes
=
@safe_max_files
*
5
.
kilobytes
# Average 5 KB per file
@
no_limits
=
!!
options
.
fetch
(
:no_limits
,
fals
e
)
@
enforce_limits
=
!!
options
.
fetch
(
:limits
,
tru
e
)
@expanded
=
!!
options
.
fetch
(
:expanded
,
true
)
@expanded
=
!!
options
.
fetch
(
:expanded
,
true
)
@line_count
=
0
@line_count
=
0
...
@@ -88,12 +88,12 @@ module Gitlab
...
@@ -88,12 +88,12 @@ module Gitlab
@iterator
.
each
do
|
raw
|
@iterator
.
each
do
|
raw
|
@empty
=
false
@empty
=
false
if
!
@no
_limits
&&
i
>=
@max_files
if
@enforce
_limits
&&
i
>=
@max_files
@overflow
=
true
@overflow
=
true
break
break
end
end
expanded
=
@no
_limits
||
@expanded
expanded
=
!
@enforce
_limits
||
@expanded
diff
=
Gitlab
::
Git
::
Diff
.
new
(
raw
,
expanded:
expanded
)
diff
=
Gitlab
::
Git
::
Diff
.
new
(
raw
,
expanded:
expanded
)
...
@@ -104,7 +104,7 @@ module Gitlab
...
@@ -104,7 +104,7 @@ module Gitlab
@line_count
+=
diff
.
line_count
@line_count
+=
diff
.
line_count
@byte_count
+=
diff
.
diff
.
bytesize
@byte_count
+=
diff
.
diff
.
bytesize
if
!
@no
_limits
&&
(
@line_count
>=
@max_lines
||
@byte_count
>=
@max_bytes
)
if
@enforce
_limits
&&
(
@line_count
>=
@max_lines
||
@byte_count
>=
@max_bytes
)
# This last Diff instance pushes us over the lines limit. We stop and
# This last Diff instance pushes us over the lines limit. We stop and
# discard it.
# discard it.
@overflow
=
true
@overflow
=
true
...
...
spec/lib/gitlab/git/diff_collection_spec.rb
View file @
04cf618b
...
@@ -6,7 +6,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -6,7 +6,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
iterator
,
iterator
,
max_files:
max_files
,
max_files:
max_files
,
max_lines:
max_lines
,
max_lines:
max_lines
,
no_limits:
no_
limits
,
limits:
limits
,
expanded:
expanded
expanded:
expanded
)
)
end
end
...
@@ -16,7 +16,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -16,7 +16,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
let
(
:line_count
)
{
1
}
let
(
:line_count
)
{
1
}
let
(
:max_files
)
{
10
}
let
(
:max_files
)
{
10
}
let
(
:max_lines
)
{
100
}
let
(
:max_lines
)
{
100
}
let
(
:
no_limits
)
{
fals
e
}
let
(
:
limits
)
{
tru
e
}
let
(
:expanded
)
{
true
}
let
(
:expanded
)
{
true
}
describe
'#to_a'
do
describe
'#to_a'
do
...
@@ -75,7 +75,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -75,7 +75,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
end
end
context
'when limiting is disabled'
do
context
'when limiting is disabled'
do
let
(
:
no_limits
)
{
tru
e
}
let
(
:
limits
)
{
fals
e
}
describe
'#overflow?'
do
describe
'#overflow?'
do
subject
{
super
().
overflow?
}
subject
{
super
().
overflow?
}
...
@@ -94,7 +94,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -94,7 +94,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
describe
'#size'
do
describe
'#size'
do
it
{
expect
(
subject
.
size
).
to
eq
(
3
)
}
it
{
expect
(
subject
.
size
).
to
eq
(
3
)
}
it
'does not change after peeking'
do
it
'does not change after peeking'
do
subject
.
any?
subject
.
any?
expect
(
subject
.
size
).
to
eq
(
3
)
expect
(
subject
.
size
).
to
eq
(
3
)
...
@@ -123,7 +123,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -123,7 +123,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
it
{
expect
(
subject
.
size
).
to
eq
(
0
)
}
it
{
expect
(
subject
.
size
).
to
eq
(
0
)
}
context
'when limiting is disabled'
do
context
'when limiting is disabled'
do
let
(
:
no_limits
)
{
tru
e
}
let
(
:
limits
)
{
fals
e
}
describe
'#overflow?'
do
describe
'#overflow?'
do
subject
{
super
().
overflow?
}
subject
{
super
().
overflow?
}
...
@@ -167,7 +167,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -167,7 +167,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
it
{
expect
(
subject
.
size
).
to
eq
(
10
)
}
it
{
expect
(
subject
.
size
).
to
eq
(
10
)
}
context
'when limiting is disabled'
do
context
'when limiting is disabled'
do
let
(
:
no_limits
)
{
tru
e
}
let
(
:
limits
)
{
fals
e
}
describe
'#overflow?'
do
describe
'#overflow?'
do
subject
{
super
().
overflow?
}
subject
{
super
().
overflow?
}
...
@@ -207,7 +207,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -207,7 +207,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
it
{
expect
(
subject
.
size
).
to
eq
(
3
)
}
it
{
expect
(
subject
.
size
).
to
eq
(
3
)
}
context
'when limiting is disabled'
do
context
'when limiting is disabled'
do
let
(
:
no_limits
)
{
tru
e
}
let
(
:
limits
)
{
fals
e
}
describe
'#overflow?'
do
describe
'#overflow?'
do
subject
{
super
().
overflow?
}
subject
{
super
().
overflow?
}
...
@@ -273,7 +273,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -273,7 +273,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
it
{
expect
(
subject
.
size
).
to
eq
(
9
)
}
it
{
expect
(
subject
.
size
).
to
eq
(
9
)
}
context
'when limiting is disabled'
do
context
'when limiting is disabled'
do
let
(
:
no_limits
)
{
tru
e
}
let
(
:
limits
)
{
fals
e
}
describe
'#overflow?'
do
describe
'#overflow?'
do
subject
{
super
().
overflow?
}
subject
{
super
().
overflow?
}
...
@@ -450,7 +450,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -450,7 +450,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
end
end
context
'when limiting is disabled'
do
context
'when limiting is disabled'
do
let
(
:
no_limits
)
{
tru
e
}
let
(
:
limits
)
{
fals
e
}
it
'yields Diff instances even when they are quite big'
do
it
'yields Diff instances even when they are quite big'
do
expect
{
|
b
|
subject
.
each
(
&
b
)
}.
expect
{
|
b
|
subject
.
each
(
&
b
)
}.
...
...
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