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
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
def
define_pipelines_vars
@pipelines
=
@merge_request
.
all_pipelines
if
@pipelines
.
any
?
if
@pipelines
.
present
?
@pipeline
=
@pipelines
.
first
@statuses
=
@pipeline
.
statuses
.
relevant
end
...
...
app/helpers/merge_requests_helper.rb
View file @
37407132
...
...
@@ -86,11 +86,15 @@ module MergeRequestsHelper
end
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?
namespace
=
link_to
(
merge_request
.
source_project_namespace
,
project_path
(
merge_request
.
source_project
))
namespace
+
":"
+
branch
else
branch
...
...
app/models/merge_request.rb
View file @
37407132
...
...
@@ -333,7 +333,7 @@ class MergeRequest < ActiveRecord::Base
end
def
closed_without_fork?
closed?
&&
(
forked_source_project_missing?
||
!
source_project
)
closed?
&&
forked_source_project_missing?
end
def
forked_source_project_missing?
...
...
@@ -344,7 +344,7 @@ class MergeRequest < ActiveRecord::Base
end
def
reopenable?
source_branch_exists?
&&
closed
?
closed?
&&
!
source_project_missing?
&&
source_branch_exists
?
end
def
ensure_merge_request_diff
...
...
@@ -656,7 +656,7 @@ class MergeRequest < ActiveRecord::Base
end
def
has_ci?
source_project
.
ci_service
&&
commits
.
any?
source_project
.
try
(
:ci_service
)
&&
commits
.
any?
end
def
branch_missing?
...
...
@@ -688,12 +688,9 @@ class MergeRequest < ActiveRecord::Base
@environments
||=
begin
environments
=
source_project
.
environments_for
(
source_branch
,
diff_head_commit
)
environments
+=
target_project
.
environments_for
(
target_branch
,
diff_head_commit
,
with_tags:
true
)
environments
.
uniq
envs
=
target_project
.
environments_for
(
target_branch
,
diff_head_commit
,
with_tags:
true
)
envs
.
concat
(
source_project
.
environments_for
(
source_branch
,
diff_head_commit
))
if
source_project
envs
.
uniq
end
end
...
...
app/views/projects/merge_requests/_show.html.haml
View file @
37407132
...
...
@@ -35,7 +35,9 @@
-
if
@merge_request
.
open?
&&
@merge_request
.
diverged_from_target_branch?
%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"
-
if
@merge_request
.
source_branch_exists?
&&
@merge_request
.
mergeable?
&&
@merge_request
.
can_be_merged_by?
(
current_user
)
...
...
@@ -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
Discussion
%span
.badge
=
@merge_request
.
mr_and_commit_notes
.
user
.
count
%li
.commits-tab
=
link_to
commits_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'div#commits'
,
action:
'commits'
,
toggle:
'tab'
}
do
Commits
%span
.badge
=
@commits_count
-
if
@merge_request
.
source_project
%li
.commits-tab
=
link_to
commits_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
data:
{
target:
'div#commits'
,
action:
'commits'
,
toggle:
'tab'
}
do
Commits
%span
.badge
=
@commits_count
-
if
@pipeline
%li
.pipelines-tab
=
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
expect
(
page
).
to
have_content
'Test merge request'
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
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