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
Tatuya Kamada
gitlab-ce
Commits
37407132
Commit
37407132
authored
Oct 19, 2016
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the merge request view when source projects or branches are removed
parent
e6f515ec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
18 deletions
+36
-18
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+7
-3
app/models/merge_request.rb
app/models/merge_request.rb
+6
-9
app/views/projects/merge_requests/_show.html.haml
app/views/projects/merge_requests/_show.html.haml
+8
-5
spec/features/merge_requests/created_from_fork_spec.rb
spec/features/merge_requests/created_from_fork_spec.rb
+14
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
37407132
...
@@ -554,7 +554,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -554,7 +554,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
define_pipelines_vars
def
define_pipelines_vars
@pipelines
=
@merge_request
.
all_pipelines
@pipelines
=
@merge_request
.
all_pipelines
if
@pipelines
.
any
?
if
@pipelines
.
present
?
@pipeline
=
@pipelines
.
first
@pipeline
=
@pipelines
.
first
@statuses
=
@pipeline
.
statuses
.
relevant
@statuses
=
@pipeline
.
statuses
.
relevant
end
end
...
...
app/helpers/merge_requests_helper.rb
View file @
37407132
...
@@ -86,11 +86,15 @@ module MergeRequestsHelper
...
@@ -86,11 +86,15 @@ module MergeRequestsHelper
end
end
def
source_branch_with_namespace
(
merge_request
)
def
source_branch_with_namespace
(
merge_request
)
branch
=
link_to
(
merge_request
.
source_branch
,
namespace_project_commits_path
(
merge_request
.
source_project
.
namespace
,
merge_request
.
source_project
,
merge_request
.
source_branch
))
namespace
=
merge_request
.
source_project_namespace
branch
=
merge_request
.
source_branch
if
merge_request
.
source_branch_exists?
namespace
=
link_to
(
namespace
,
project_path
(
merge_request
.
source_project
))
branch
=
link_to
(
branch
,
namespace_project_commits_path
(
merge_request
.
source_project
.
namespace
,
merge_request
.
source_project
,
merge_request
.
source_branch
))
end
if
merge_request
.
for_fork?
if
merge_request
.
for_fork?
namespace
=
link_to
(
merge_request
.
source_project_namespace
,
project_path
(
merge_request
.
source_project
))
namespace
+
":"
+
branch
namespace
+
":"
+
branch
else
else
branch
branch
...
...
app/models/merge_request.rb
View file @
37407132
...
@@ -333,7 +333,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -333,7 +333,7 @@ class MergeRequest < ActiveRecord::Base
end
end
def
closed_without_fork?
def
closed_without_fork?
closed?
&&
(
forked_source_project_missing?
||
!
source_project
)
closed?
&&
forked_source_project_missing?
end
end
def
forked_source_project_missing?
def
forked_source_project_missing?
...
@@ -344,7 +344,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -344,7 +344,7 @@ class MergeRequest < ActiveRecord::Base
end
end
def
reopenable?
def
reopenable?
source_branch_exists?
&&
closed
?
closed?
&&
!
source_project_missing?
&&
source_branch_exists
?
end
end
def
ensure_merge_request_diff
def
ensure_merge_request_diff
...
@@ -656,7 +656,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -656,7 +656,7 @@ class MergeRequest < ActiveRecord::Base
end
end
def
has_ci?
def
has_ci?
source_project
.
ci_service
&&
commits
.
any?
source_project
.
try
(
:ci_service
)
&&
commits
.
any?
end
end
def
branch_missing?
def
branch_missing?
...
@@ -688,12 +688,9 @@ class MergeRequest < ActiveRecord::Base
...
@@ -688,12 +688,9 @@ class MergeRequest < ActiveRecord::Base
@environments
||=
@environments
||=
begin
begin
environments
=
source_project
.
environments_for
(
envs
=
target_project
.
environments_for
(
target_branch
,
diff_head_commit
,
with_tags:
true
)
source_branch
,
diff_head_commit
)
envs
.
concat
(
source_project
.
environments_for
(
source_branch
,
diff_head_commit
))
if
source_project
environments
+=
target_project
.
environments_for
(
envs
.
uniq
target_branch
,
diff_head_commit
,
with_tags:
true
)
environments
.
uniq
end
end
end
end
...
...
app/views/projects/merge_requests/_show.html.haml
View file @
37407132
...
@@ -35,7 +35,9 @@
...
@@ -35,7 +35,9 @@
-
if
@merge_request
.
open?
&&
@merge_request
.
diverged_from_target_branch?
-
if
@merge_request
.
open?
&&
@merge_request
.
diverged_from_target_branch?
%span
(
#{
pluralize
(
@merge_request
.
diverged_commits_count
,
'commit'
)
}
behind)
%span
(
#{
pluralize
(
@merge_request
.
diverged_commits_count
,
'commit'
)
}
behind)
=
render
"projects/merge_requests/show/how_to_merge"
-
if
@merge_request
.
source_branch_exists?
=
render
"projects/merge_requests/show/how_to_merge"
=
render
"projects/merge_requests/widget/show.html.haml"
=
render
"projects/merge_requests/widget/show.html.haml"
-
if
@merge_request
.
source_branch_exists?
&&
@merge_request
.
mergeable?
&&
@merge_request
.
can_be_merged_by?
(
current_user
)
-
if
@merge_request
.
source_branch_exists?
&&
@merge_request
.
mergeable?
&&
@merge_request
.
can_be_merged_by?
(
current_user
)
...
@@ -50,10 +52,11 @@
...
@@ -50,10 +52,11 @@
=
link_to
namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'div#notes'
,
action:
'notes'
,
toggle:
'tab'
}
do
=
link_to
namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'div#notes'
,
action:
'notes'
,
toggle:
'tab'
}
do
Discussion
Discussion
%span
.badge
=
@merge_request
.
mr_and_commit_notes
.
user
.
count
%span
.badge
=
@merge_request
.
mr_and_commit_notes
.
user
.
count
%li
.commits-tab
-
if
@merge_request
.
source_project
=
link_to
commits_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'div#commits'
,
action:
'commits'
,
toggle:
'tab'
}
do
%li
.commits-tab
Commits
=
link_to
commits_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'div#commits'
,
action:
'commits'
,
toggle:
'tab'
}
do
%span
.badge
=
@commits_count
Commits
%span
.badge
=
@commits_count
-
if
@pipeline
-
if
@pipeline
%li
.pipelines-tab
%li
.pipelines-tab
=
link_to
pipelines_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'#pipelines'
,
action:
'pipelines'
,
toggle:
'tab'
}
do
=
link_to
pipelines_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'#pipelines'
,
action:
'pipelines'
,
toggle:
'tab'
}
do
...
...
spec/features/merge_requests/created_from_fork_spec.rb
View file @
37407132
...
@@ -25,6 +25,20 @@ feature 'Merge request created from fork' do
...
@@ -25,6 +25,20 @@ feature 'Merge request created from fork' do
expect
(
page
).
to
have_content
'Test merge request'
expect
(
page
).
to
have_content
'Test merge request'
end
end
context
'source project is deleted'
do
background
do
MergeRequests
::
MergeService
.
new
(
project
,
user
).
execute
(
merge_request
)
fork_project
.
destroy!
end
scenario
'user can access merge request'
do
visit_merge_request
(
merge_request
)
expect
(
page
).
to
have_content
'Test merge request'
expect
(
page
).
to
have_content
"(removed):
#{
merge_request
.
source_branch
}
"
end
end
context
'pipeline present in source project'
do
context
'pipeline present in source project'
do
include
WaitForAjax
include
WaitForAjax
...
...
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