Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-09-22 17:57:35 +0300
committerRémy Coutable <remy@rymai.me>2017-10-05 11:48:25 +0300
commitf8184cec8590f476419497bfe0504da6e253e4c1 (patch)
tree3cd5d82d8df840b87d931a3f8dde57a609466785
parent324f672eefcd3db1337d51f5137dd085c4697c8c (diff)
Don't check for commit existence in Github::Representation::Branch#exists?
We don't need to check if the existing branch contains a specific SHA since we only use the branch's name, the SHA is taken from the pull request raw `sha` data. Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--lib/github/representation/branch.rb12
-rw-r--r--lib/github/representation/pull_request.rb2
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