Intead of showing 404 give users ability to close MR with missing branches

This commit is contained in:
Dmitriy Zaporozhets 2013-03-20 20:22:29 +02:00
parent a0cc38827f
commit a163135cb5
6 changed files with 40 additions and 16 deletions

View file

@ -543,3 +543,15 @@ img.emoji {
.appear-data {
display: none;
}
.label-branch {
@include border-radius(4px);
padding: 2px 4px;
border: none;
font-size: 14px;
background: #474D57;
color: #fff;
font-family: $monospace_font;
text-shadow: 0 1px 1px #111;
font-weight: normal;
}

View file

@ -70,16 +70,6 @@ li.merge_request {
@extend .append-bottom-10;
}
.label_branch {
@include border-radius(4px);
padding: 2px 4px;
border: none;
font-size: 14px;
background: #474D57;
color: #fff;
font-family: $monospace_font;
}
.mr_source_commit,
.mr_target_commit {
.commit {

View file

@ -129,11 +129,11 @@ class MergeRequestsController < ProjectResourceController
def validates_merge_request
# Show git not found page if target branch doesn't exist
return git_not_found! unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch)
return invalid_mr unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch)
# Show git not found page if source branch doesn't exist
# and there is no saved commits between source & target branch
return git_not_found! if !@project.repo.heads.map(&:name).include?(@merge_request.source_branch) && @merge_request.commits.blank?
return invalid_mr if !@project.repo.heads.map(&:name).include?(@merge_request.source_branch) && @merge_request.commits.blank?
end
def define_show_vars
@ -158,4 +158,9 @@ class MergeRequestsController < ProjectResourceController
can?(current_user, action, @project)
end
def invalid_mr
# Render special view for MR with removed source or target branch
render 'invalid'
end
end

View file

@ -2,9 +2,9 @@
- unless params[:to]
%p.slead
Fill input field with commit id like
%code.label_branch 4eedf23
%code.label-branch 4eedf23
or branch/tag name like
%code.label_branch master
%code.label-branch master
and press compare button for commits list, code diff.
%br

View file

@ -0,0 +1,17 @@
.merge-request
= render "merge_requests/show/mr_title"
= render "merge_requests/show/mr_box"
.alert.alert-error
%h5
%i.icon-exclamation-sign
We cannot find
%span.label-branch= @merge_request.source_branch
or
%span.label-branch= @merge_request.target_branch
branches in the repository.
%p
Maybe it was removed or never pushed.
%p
Please close Merge Request or change branches with existing one

View file

@ -1,9 +1,9 @@
%h3.page_title
= "Merge Request ##{@merge_request.id}:"
&nbsp;
%span.label_branch= @merge_request.source_branch
%span.label-branch= @merge_request.source_branch
&rarr;
%span.label_branch= @merge_request.target_branch
%span.label-branch= @merge_request.target_branch
%span.pull-right
- if can?(current_user, :modify_merge_request, @merge_request)