BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f00ee5c2
Commit
f00ee5c2
authored
Oct 19, 2016
by
Nick Thomas
Committed by
blackst0ne
Oct 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the merge request view when source projects or branches are removed
parent
b6c85997
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
18 deletions
+36
-18
merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+7
-3
merge_request.rb
app/models/merge_request.rb
+6
-9
_show.html.haml
app/views/projects/merge_requests/_show.html.haml
+8
-5
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 @
f00ee5c2
...
...
@@ -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 @
f00ee5c2
...
...
@@ -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 @
f00ee5c2
...
...
@@ -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 @
f00ee5c2
...
...
@@ -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 @
f00ee5c2
...
...
@@ -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