summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2017-06-08 15:01:10 +0200
committerJames Lopez <james@jameslopez.es>2017-06-08 15:01:10 +0200
commitd0ad2b97b14f1f9873b4e18d2269773c34fbd7e5 (patch)
tree4d1da25ae31ac5bfcfba008477b26a927e99e30c
parentfd072e2221147f52edf74d4dcedb2ffa3799ab2f (diff)
downloadgitlab-ce-d0ad2b97b14f1f9873b4e18d2269773c34fbd7e5.tar.gz
Fix branch existence check so it only calls git contains once
-rw-r--r--lib/github/import.rb2
-rw-r--r--lib/github/representation/branch.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/github/import.rb b/lib/github/import.rb
index 9c7eb965f93..9f371378b63 100644
--- a/lib/github/import.rb
+++ b/lib/github/import.rb
@@ -336,6 +336,8 @@ module Github
def restore_target_branch(pull_request)
repository.create_branch(pull_request.target_branch_name, pull_request.target_branch_sha)
+
+ pull_request.target_branch.confirm_branch_existence
end
def remove_branch(name)
diff --git a/lib/github/representation/branch.rb b/lib/github/representation/branch.rb
index d1dac6944f0..da04a9beedb 100644
--- a/lib/github/representation/branch.rb
+++ b/lib/github/representation/branch.rb
@@ -26,7 +26,11 @@ module Github
end
def exists?
- branch_exists? && commit_exists?
+ @exists ||= branch_exists? && commit_exists?
+ end
+
+ def confirm_branch_existence
+ @exists = commit_exists?
end
def valid?