From 9b1a321270408e5b642bb3f866769d51d38b155f Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 7 Sep 2017 08:47:15 +0200 Subject: fix a few issues to do with pull request branches --- lib/github/representation/pull_request.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/github/representation/pull_request.rb b/lib/github/representation/pull_request.rb index c6a337ddc50..ec030ade38a 100644 --- a/lib/github/representation/pull_request.rb +++ b/lib/github/representation/pull_request.rb @@ -10,9 +10,9 @@ module Github def source_branch_name @source_branch_name ||= - if !opened? && !source_branch_exists? - source_branch_ref - elsif cross_project? + if opened? && project.repository.branch_exists?(source_branch.ref) + source_branch.ref + elsif cross_project? && opened? source_branch_name_prefixed else source_branch_ref @@ -22,7 +22,7 @@ module Github def source_branch_exists? return @source_branch_exists if defined?(@source_branch_exists) - @source_branch_exists = repository.branch_exists?(source_branch_name) + @source_branch_exists = project.repository.branch_exists?(source_branch_name) end def target_project @@ -68,11 +68,11 @@ module Github end def source_branch_ref - "refs/merge-requests/#{pull_request.iid}/head" + "refs/merge-requests/#{iid}/head" end def source_branch_name_prefixed - "gh-#{target_branch_short_sha}/#{iid}/#{source_branch_user}/#{source_branch_ref}" + "gh-#{target_branch_short_sha}/#{iid}/#{source_branch_user}/#{source_branch.ref}" end def target_branch -- cgit v1.2.1