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
ff650aa8
Commit
ff650aa8
authored
Mar 26, 2020
by
Gary Holtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moves some entity code to avoid a fixture error
parent
9b641b7b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
app/serializers/diffs_entity.rb
app/serializers/diffs_entity.rb
+18
-14
No files found.
app/serializers/diffs_entity.rb
View file @
ff650aa8
...
...
@@ -17,20 +17,7 @@ class DiffsEntity < Grape::Entity
end
expose
:commit
do
|
diffs
,
options
|
if
options
[
:commit
]
neighbors
=
commits
(
options
[
:commit
].
id
)
if
options
[
:commit
]
prev_commit_id
=
neighbors
[
:prev_commit_id
]
next_commit_id
=
neighbors
[
:next_commit_id
]
end
CommitEntity
.
represent
options
[
:commit
],
options
.
merge
(
type: :full
,
commit_url_params:
{
merge_request_iid:
merge_request
&
.
iid
},
pipeline_ref:
merge_request
&
.
source_branch
,
pipeline_project:
merge_request
&
.
source_project
,
prev_commit_id:
prev_commit_id
,
next_commit_id:
next_commit_id
)
CommitEntity
.
represent
options
[
:commit
],
commit_options
(
options
)
end
expose
:context_commits
,
using:
API
::
Entities
::
Commit
,
if:
->
(
diffs
,
options
)
{
merge_request
&
.
project
&
.
context_commits_enabled?
}
do
|
diffs
|
...
...
@@ -90,6 +77,8 @@ class DiffsEntity < Grape::Entity
options
[
:merge_request
]
end
private
def
commit_ids
strong_memoize
(
:commit_ids
)
do
[
nil
]
+
merge_request
.
commits
.
collect
(
&
:id
)
+
[
nil
]
...
...
@@ -101,4 +90,19 @@ class DiffsEntity < Grape::Entity
{
prev_commit_id:
prev_commit
,
next_commit_id:
next_commit
}
if
commit
==
id
end
end
def
commit_options
(
options
)
neighbors
=
commits
(
options
[
:commit
].
id
)
prev_commit_id
=
neighbors
.
try
(
:prev_commit_id
)
next_commit_id
=
neighbors
.
try
(
:next_commit_id
)
options
.
merge
(
type: :full
,
commit_url_params:
{
merge_request_iid:
merge_request
&
.
iid
},
pipeline_ref:
merge_request
&
.
source_branch
,
pipeline_project:
merge_request
&
.
source_project
,
prev_commit_id:
prev_commit_id
,
next_commit_id:
next_commit_id
)
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