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
1e075ea9
Commit
1e075ea9
authored
Jun 18, 2021
by
Robert May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cache_action to repository compare
parent
bf7b31d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
15 deletions
+27
-15
config/feature_flags/development/api_caching_rate_limit_repository_compare.yml
...development/api_caching_rate_limit_repository_compare.yml
+8
-0
lib/api/repositories.rb
lib/api/repositories.rb
+19
-15
No files found.
config/feature_flags/development/api_caching_rate_limit_repository_compare.yml
0 → 100644
View file @
1e075ea9
---
name
:
api_caching_rate_limit_repository_compare
introduced_by_url
:
rollout_issue_url
:
milestone
:
'
14.0'
type
:
development
group
:
group::source code
default_enabled
:
false
lib/api/repositories.rb
View file @
1e075ea9
...
...
@@ -120,24 +120,28 @@ module API
optional
:straight
,
type:
Boolean
,
desc:
'Comparison method, `true` for direct comparison between `from` and `to` (`from`..`to`), `false` to compare using merge base (`from`...`to`)'
,
default:
false
end
get
':id/repository/compare'
do
if
params
[
:from_project_id
].
present?
target_project
=
MergeRequestTargetProjectFinder
.
new
(
current_user:
current_user
,
source_project:
user_project
,
project_feature: :repository
)
.
execute
(
include_routes:
true
).
find_by_id
(
params
[
:from_project_id
])
if
target_project
.
blank?
render_api_error!
(
"Target project id:
#{
params
[
:from_project_id
]
}
is not a fork of project id:
#{
params
[
:id
]
}
"
,
400
)
ff_enabled
=
Feature
.
enabled?
(
:api_caching_rate_limit_repository_compare
,
user_project
,
default_enabled: :yaml
)
cache_action_if
(
ff_enabled
,
[
user_project
,
:repository_compare
,
current_user
,
declared_params
],
expires_in:
30
.
seconds
)
do
if
params
[
:from_project_id
].
present?
target_project
=
MergeRequestTargetProjectFinder
.
new
(
current_user:
current_user
,
source_project:
user_project
,
project_feature: :repository
)
.
execute
(
include_routes:
true
).
find_by_id
(
params
[
:from_project_id
])
if
target_project
.
blank?
render_api_error!
(
"Target project id:
#{
params
[
:from_project_id
]
}
is not a fork of project id:
#{
params
[
:id
]
}
"
,
400
)
end
else
target_project
=
user_project
end
else
target_project
=
user_project
end
compare
=
CompareService
.
new
(
user_project
,
params
[
:to
]).
execute
(
target_project
,
params
[
:from
],
straight:
params
[
:straight
])
compare
=
CompareService
.
new
(
user_project
,
params
[
:to
]).
execute
(
target_project
,
params
[
:from
],
straight:
params
[
:straight
])
if
compare
present
compare
,
with:
Entities
::
Compare
else
not_found!
(
"Ref"
)
if
compare
present
compare
,
with:
Entities
::
Compare
else
not_found!
(
"Ref"
)
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