summaryrefslogtreecommitdiff
path: root/lib/gitlab/github_import
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2017-03-10 20:40:14 +0100
committerGabriel Mazetto <brodock@gmail.com>2017-03-10 21:13:45 +0100
commita996880bf7d5d94b1bca7be84bd00b18e37da337 (patch)
treef8681ac5bea964a361471f79358d56b9b150aaac /lib/gitlab/github_import
parent42ac3055b1686847c9e2dc838c138aa85ca3763b (diff)
downloadgitlab-ce-a996880bf7d5d94b1bca7be84bd00b18e37da337.tar.gz
Using guard clause and added more specs29046-fix-github-importer-open-prs
Diffstat (limited to 'lib/gitlab/github_import')
-rw-r--r--lib/gitlab/github_import/importer.rb4
-rw-r--r--lib/gitlab/github_import/pull_request_formatter.rb8
2 files changed, 3 insertions, 9 deletions
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb
index 055a07781a5..eea4a91f17d 100644
--- a/lib/gitlab/github_import/importer.rb
+++ b/lib/gitlab/github_import/importer.rb
@@ -148,7 +148,7 @@ module Gitlab
rescue => e
errors << { type: :pull_request, url: Gitlab::UrlSanitizer.sanitize(gh_pull_request.url), errors: e.message }
ensure
- clean_up_restored_branches(gh_pull_request) unless gh_pull_request.opened?
+ clean_up_restored_branches(gh_pull_request)
end
end
end
@@ -171,6 +171,8 @@ module Gitlab
end
def clean_up_restored_branches(pull_request)
+ return if pull_request.opened?
+
remove_branch(pull_request.source_branch_name) unless pull_request.source_branch_exists?
remove_branch(pull_request.target_branch_name) unless pull_request.target_branch_exists?
end
diff --git a/lib/gitlab/github_import/pull_request_formatter.rb b/lib/gitlab/github_import/pull_request_formatter.rb
index 0a31e3888bd..add7236e339 100644
--- a/lib/gitlab/github_import/pull_request_formatter.rb
+++ b/lib/gitlab/github_import/pull_request_formatter.rb
@@ -64,14 +64,6 @@ module Gitlab
state == 'opened'
end
- def closed?
- state == 'closed'
- end
-
- def merged?
- state == 'merged'
- end
-
private
def state