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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
e22514fd
Commit
e22514fd
authored
Nov 18, 2016
by
Adam Niedzielski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide empty merge request diffs when comparing versions
parent
9e9965ba
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
7 deletions
+14
-7
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+2
-2
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+4
-2
changelogs/unreleased/hide-empty-merge-request-diffs.yml
changelogs/unreleased/hide-empty-merge-request-diffs.yml
+4
-0
spec/features/merge_requests/merge_request_versions_spec.rb
spec/features/merge_requests/merge_request_versions_spec.rb
+4
-3
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
e22514fd
...
...
@@ -82,12 +82,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request_diff
=
if
params
[
:diff_id
]
@merge_request
.
merge_request_diffs
.
find
(
params
[
:diff_id
])
@merge_request
.
merge_request_diffs
.
viewable
.
find
(
params
[
:diff_id
])
else
@merge_request
.
merge_request_diff
end
@merge_request_diffs
=
@merge_request
.
merge_request_diffs
.
select_without_diff
@merge_request_diffs
=
@merge_request
.
merge_request_diffs
.
viewable
.
select_without_diff
@comparable_diffs
=
@merge_request_diffs
.
select
{
|
diff
|
diff
.
id
<
@merge_request_diff
.
id
}
if
params
[
:start_sha
].
present?
...
...
app/models/merge_request_diff.rb
View file @
e22514fd
...
...
@@ -11,6 +11,9 @@ class MergeRequestDiff < ActiveRecord::Base
belongs_to
:merge_request
serialize
:st_commits
serialize
:st_diffs
state_machine
:state
,
initial: :empty
do
state
:collected
state
:overflow
...
...
@@ -22,8 +25,7 @@ class MergeRequestDiff < ActiveRecord::Base
state
:overflow_diff_lines_limit
end
serialize
:st_commits
serialize
:st_diffs
scope
:viewable
,
->
{
without_state
(
:empty
)
}
# All diff information is collected from repository after object is created.
# It allows you to override variables like head_commit_sha before getting diff.
...
...
changelogs/unreleased/hide-empty-merge-request-diffs.yml
0 → 100644
View file @
e22514fd
---
title
:
Fix errors happening when source branch of merge request is removed and then restored
merge_request
:
7568
author
:
spec/features/merge_requests/merge_request_versions_spec.rb
View file @
e22514fd
...
...
@@ -3,11 +3,12 @@ require 'spec_helper'
feature
'Merge Request versions'
,
js:
true
,
feature:
true
do
let
(
:merge_request
)
{
create
(
:merge_request
,
importing:
true
)
}
let
(
:project
)
{
merge_request
.
source_project
}
let!
(
:merge_request_diff1
)
{
merge_request
.
merge_request_diffs
.
create
(
head_commit_sha:
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
}
let!
(
:merge_request_diff2
)
{
merge_request
.
merge_request_diffs
.
create
(
head_commit_sha:
nil
)
}
let!
(
:merge_request_diff3
)
{
merge_request
.
merge_request_diffs
.
create
(
head_commit_sha:
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
)
}
before
do
login_as
:admin
merge_request
.
merge_request_diffs
.
create
(
head_commit_sha:
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
merge_request
.
merge_request_diffs
.
create
(
head_commit_sha:
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
)
visit
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
...
...
@@ -53,7 +54,7 @@ feature 'Merge Request versions', js: true, feature: true do
project
.
namespace
,
project
,
merge_request
.
iid
,
diff_id:
2
,
diff_id:
merge_request_diff3
.
id
,
start_sha:
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
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