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
d8561f3a
Commit
d8561f3a
authored
Nov 18, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore empty MR diffs when migrating to external storage
parent
523e0b19
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
1 deletion
+13
-1
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+2
-1
changelogs/unreleased/36646-ignore-empty-diffs-for-external-diffs-migration.yml
...36646-ignore-empty-diffs-for-external-diffs-migration.yml
+5
-0
spec/models/merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+6
-0
No files found.
app/models/merge_request_diff.rb
View file @
d8561f3a
...
...
@@ -49,13 +49,14 @@ class MergeRequestDiff < ApplicationRecord
scope
:by_commit_sha
,
->
(
sha
)
do
joins
(
:merge_request_diff_commits
).
where
(
merge_request_diff_commits:
{
sha:
sha
}).
reorder
(
nil
)
end
scope
:has_diff_files
,
->
{
where
(
id:
MergeRequestDiffFile
.
select
(
:merge_request_diff_id
))
}
scope
:by_project_id
,
->
(
project_id
)
do
joins
(
:merge_request
).
where
(
merge_requests:
{
target_project_id:
project_id
})
end
scope
:recent
,
->
{
order
(
id: :desc
).
limit
(
100
)
}
scope
:files_in_database
,
->
{
where
(
stored_externally:
[
false
,
nil
])
}
scope
:files_in_database
,
->
{
has_diff_files
.
where
(
stored_externally:
[
false
,
nil
])
}
scope
:not_latest_diffs
,
->
do
merge_requests
=
MergeRequest
.
arel_table
...
...
changelogs/unreleased/36646-ignore-empty-diffs-for-external-diffs-migration.yml
0 → 100644
View file @
d8561f3a
---
title
:
Ignore empty MR diffs when migrating to external storage
merge_request
:
20296
author
:
type
:
fixed
spec/models/merge_request_diff_spec.rb
View file @
d8561f3a
...
...
@@ -98,6 +98,12 @@ describe MergeRequestDiff do
end
it
{
is_expected
.
to
contain_exactly
(
outdated
.
id
,
latest
.
id
,
closed
.
id
,
merged
.
id
,
closed_recently
.
id
,
merged_recently
.
id
)
}
it
'ignores diffs with 0 files'
do
MergeRequestDiffFile
.
where
(
merge_request_diff_id:
[
closed_recently
.
id
,
merged_recently
.
id
]).
delete_all
is_expected
.
to
contain_exactly
(
outdated
.
id
,
latest
.
id
,
closed
.
id
,
merged
.
id
)
end
end
context
'external diffs are enabled for outdated diffs'
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