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
4a91d958
Commit
4a91d958
authored
Oct 19, 2021
by
Robert May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check commit limit is used
parent
bb179a08
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
app/controllers/projects/commits_controller.rb
app/controllers/projects/commits_controller.rb
+3
-1
spec/controllers/projects/commits_controller_spec.rb
spec/controllers/projects/commits_controller_spec.rb
+12
-5
No files found.
app/controllers/projects/commits_controller.rb
View file @
4a91d958
...
@@ -6,6 +6,8 @@ class Projects::CommitsController < Projects::ApplicationController
...
@@ -6,6 +6,8 @@ class Projects::CommitsController < Projects::ApplicationController
include
ExtractsPath
include
ExtractsPath
include
RendersCommits
include
RendersCommits
COMMITS_DEFAULT_LIMIT
=
40
prepend_before_action
(
only:
[
:show
])
{
authenticate_sessionless_user!
(
:rss
)
}
prepend_before_action
(
only:
[
:show
])
{
authenticate_sessionless_user!
(
:rss
)
}
around_action
:allow_gitaly_ref_name_caching
around_action
:allow_gitaly_ref_name_caching
before_action
:require_non_empty_project
before_action
:require_non_empty_project
...
@@ -65,7 +67,7 @@ class Projects::CommitsController < Projects::ApplicationController
...
@@ -65,7 +67,7 @@ class Projects::CommitsController < Projects::ApplicationController
render_404
unless
@path
.
empty?
||
request
.
format
==
:atom
||
@repository
.
blob_at
(
@commit
.
id
,
@path
)
||
@repository
.
tree
(
@commit
.
id
,
@path
).
entries
.
present?
render_404
unless
@path
.
empty?
||
request
.
format
==
:atom
||
@repository
.
blob_at
(
@commit
.
id
,
@path
)
||
@repository
.
tree
(
@commit
.
id
,
@path
).
entries
.
present?
limit
=
params
[
:limit
].
to_i
limit
=
params
[
:limit
].
to_i
@limit
=
limit
>
0
?
limit
:
40
# limit can only ever be a positive number
@limit
=
limit
>
0
?
limit
:
COMMITS_DEFAULT_LIMIT
# limit can only ever be a positive number
@offset
=
(
params
[
:offset
]
||
0
).
to_i
@offset
=
(
params
[
:offset
]
||
0
).
to_i
search
=
params
[
:search
]
search
=
params
[
:search
]
author
=
params
[
:author
]
author
=
params
[
:author
]
...
...
spec/controllers/projects/commits_controller_spec.rb
View file @
4a91d958
...
@@ -68,7 +68,16 @@ RSpec.describe Projects::CommitsController do
...
@@ -68,7 +68,16 @@ RSpec.describe Projects::CommitsController do
end
end
context
"with an invalid limit"
do
context
"with an invalid limit"
do
before
do
let
(
:id
)
{
"master/README.md"
}
it
"uses the default limit"
do
expect_any_instance_of
(
Repository
).
to
receive
(
:commits
).
with
(
"master"
,
path:
"README.md"
,
limit:
described_class
::
COMMITS_DEFAULT_LIMIT
,
offset:
0
).
and_call_original
get
(
:show
,
get
(
:show
,
params:
{
params:
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
...
@@ -76,11 +85,9 @@ RSpec.describe Projects::CommitsController do
...
@@ -76,11 +85,9 @@ RSpec.describe Projects::CommitsController do
id:
id
,
id:
id
,
limit:
"foo"
limit:
"foo"
})
})
end
let
(
:id
)
{
'master/README.md'
}
expect
(
response
).
to
be_successful
end
it
{
is_expected
.
to
respond_with
(
:success
)
}
end
end
context
"when the ref name ends in .atom"
do
context
"when the ref name ends in .atom"
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