Commit 45b18365d5f409f196a02a4e6e2b77b8ebef909b

Authored by Dmitriy Zaporozhets
1 parent ac3c23f9

Fix an issue with MR unavailable if remove source branch

Showing 1 changed file with 8 additions and 5 deletions   Show diff stats
app/controllers/merge_requests_controller.rb
@@ -34,11 +34,14 @@ class MergeRequestsController < ApplicationController @@ -34,11 +34,14 @@ class MergeRequestsController < ApplicationController
34 end 34 end
35 35
36 def show 36 def show
37 - unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch) &&  
38 - @project.repo.heads.map(&:name).include?(@merge_request.source_branch)  
39 - git_not_found! and return  
40 - end  
41 - 37 + # Show git not found page if target branch doesnt exist
  38 + return git_not_found! unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch)
  39 +
  40 + # Show git not found page if source branch doesnt exist
  41 + # and there is no saved commits between source & target branch
  42 + return git_not_found! if !@project.repo.heads.map(&:name).include?(@merge_request.source_branch) && @merge_request.commits.blank?
  43 +
  44 + # Build a note object for comment form
42 @note = @project.notes.new(:noteable => @merge_request) 45 @note = @project.notes.new(:noteable => @merge_request)
43 46
44 # Get commits from repository 47 # Get commits from repository