From 45b18365d5f409f196a02a4e6e2b77b8ebef909b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Apr 2012 23:06:45 +0300 Subject: [PATCH] Fix an issue with MR unavailable if remove source branch --- app/controllers/merge_requests_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index f882028fcab..500406c919c 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -34,11 +34,14 @@ class MergeRequestsController < ApplicationController end def show - unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch) && - @project.repo.heads.map(&:name).include?(@merge_request.source_branch) - git_not_found! and return - end + # Show git not found page if target branch doesnt exist + return git_not_found! unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch) + # Show git not found page if source branch doesnt 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? + + # Build a note object for comment form @note = @project.notes.new(:noteable => @merge_request) # Get commits from repository