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
6bfbc3c6
Commit
6bfbc3c6
authored
Mar 26, 2020
by
Gary Holtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some quick refactors to make the pipelines pass
Also makes the code a little more verbose
parent
ff650aa8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
app/serializers/diffs_entity.rb
app/serializers/diffs_entity.rb
+6
-7
spec/serializers/diffs_entity_spec.rb
spec/serializers/diffs_entity_spec.rb
+2
-2
No files found.
app/serializers/diffs_entity.rb
View file @
6bfbc3c6
...
@@ -85,16 +85,15 @@ class DiffsEntity < Grape::Entity
...
@@ -85,16 +85,15 @@ class DiffsEntity < Grape::Entity
end
end
end
end
def
commits
(
id
)
def
commit_with_neighbors
(
id
)
commit_ids
.
each_cons
(
3
)
do
|
prev_commit
,
commit
,
next_commit
|
commits
=
commit_ids
.
each_cons
(
3
).
find
{
|
prev_commit
,
commit
,
next_commit
|
commit
==
id
}
{
prev_commit_id:
prev_commit
,
next_commit_id:
next_commit
}
if
commit
==
id
{
prev_commit_id:
commits
.
first
,
next_commit_id:
commits
.
last
}
if
commits
end
end
end
def
commit_options
(
options
)
def
commit_options
(
options
)
neighbors
=
commit
s
(
options
[
:commit
]
.
id
)
neighbors
=
commit
_with_neighbors
(
options
[
:commit
]
&
.
id
)
prev_commit_id
=
neighbors
.
try
(
:prev_commit_id
)
prev_commit_id
=
neighbors
&
.
dig
(
:prev_commit_id
)
next_commit_id
=
neighbors
.
try
(
:next_commit_id
)
next_commit_id
=
neighbors
&
.
dig
(
:next_commit_id
)
options
.
merge
(
options
.
merge
(
type: :full
,
type: :full
,
...
...
spec/serializers/diffs_entity_spec.rb
View file @
6bfbc3c6
...
@@ -28,8 +28,8 @@ describe DiffsEntity do
...
@@ -28,8 +28,8 @@ describe DiffsEntity do
end
end
context
"when a commit_id is passed"
do
context
"when a commit_id is passed"
do
let
(
:commits
)
{
merge_request
.
commits
}
let
(
:commits
)
{
[
nil
]
+
merge_request
.
commits
+
[
nil
]
}
let
(
:commit
)
{
commits
.
sample
}
let
(
:commit
)
{
commits
.
compact
.
sample
}
let
(
:entity
)
do
let
(
:entity
)
do
described_class
.
new
(
merge_request_diffs
.
first
.
diffs
,
request:
request
,
merge_request:
merge_request
,
merge_request_diffs:
merge_request_diffs
,
commit:
commit
)
described_class
.
new
(
merge_request_diffs
.
first
.
diffs
,
request:
request
,
merge_request:
merge_request
,
merge_request_diffs:
merge_request_diffs
,
commit:
commit
)
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