diff options
-rw-r--r-- | lib/github/representation/branch.rb | 12 | ||||
-rw-r--r-- | lib/github/representation/pull_request.rb | 2 |
2 files changed, 5 insertions, 9 deletions
diff --git a/lib/github/representation/branch.rb b/lib/github/representation/branch.rb index 823e8e9a9c4..25b42994ab7 100644 --- a/lib/github/representation/branch.rb +++ b/lib/github/representation/branch.rb @@ -26,7 +26,9 @@ module Github end def exists? - @exists ||= branch_exists? && commit_exists? + return @exists if defined?(@exists) + + @exists = repository.branch_exists?(ref) end def valid? @@ -47,14 +49,6 @@ module Github private - def branch_exists? - repository.branch_exists?(ref) - end - - def commit_exists? - repository.branch_names_contains(sha).include?(ref) - end - def repository @repository ||= options.fetch(:repository) end diff --git a/lib/github/representation/pull_request.rb b/lib/github/representation/pull_request.rb index 684cf54e154..9a897c5b64c 100644 --- a/lib/github/representation/pull_request.rb +++ b/lib/github/representation/pull_request.rb @@ -27,6 +27,8 @@ module Github end def target_branch_exists? + return @target_branch_exists if defined?(@target_branch_exists) + @target_branch_exists ||= target_branch.exists? end |