summaryrefslogtreecommitdiff
path: root/lib/gitlab/github_import
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2017-03-26 03:16:27 +0200
committerGabriel Mazetto <brodock@gmail.com>2017-04-03 12:45:31 +0200
commit3c75ee2823e813e22d357a1f2a7ce21e23be77fb (patch)
tree8118d00419b6317b793f5103ba0518327e0a3b72 /lib/gitlab/github_import
parentc8273ba85898877e47dbb28d0a4a5664f3bf4196 (diff)
downloadgitlab-ce-3c75ee2823e813e22d357a1f2a7ce21e23be77fb.tar.gz
Minor refactor
Diffstat (limited to 'lib/gitlab/github_import')
-rw-r--r--lib/gitlab/github_import/branch_formatter.rb4
-rw-r--r--lib/gitlab/github_import/pull_request_formatter.rb15
2 files changed, 7 insertions, 12 deletions
diff --git a/lib/gitlab/github_import/branch_formatter.rb b/lib/gitlab/github_import/branch_formatter.rb
index 81d8715b854..8aa885fb811 100644
--- a/lib/gitlab/github_import/branch_formatter.rb
+++ b/lib/gitlab/github_import/branch_formatter.rb
@@ -15,8 +15,8 @@ module Gitlab
raw_data.user&.login || 'unknown'
end
- def short_sha(length = 7)
- sha.to_s[0..length]
+ def short_sha
+ Commit.truncate_sha(sha)
end
private
diff --git a/lib/gitlab/github_import/pull_request_formatter.rb b/lib/gitlab/github_import/pull_request_formatter.rb
index 82be1639578..38660a7ccca 100644
--- a/lib/gitlab/github_import/pull_request_formatter.rb
+++ b/lib/gitlab/github_import/pull_request_formatter.rb
@@ -37,13 +37,12 @@ module Gitlab
end
def source_branch_name
- @source_branch_name ||= begin
- if cross_project?
+ @source_branch_name ||=
+ if cross_project? || !source_branch_exists?
source_branch_name_prefixed
else
- source_branch_exists? ? source_branch_ref : source_branch_name_prefixed
+ source_branch_ref
end
- end
end
def source_branch_name_prefixed
@@ -51,9 +50,7 @@ module Gitlab
end
def source_branch_exists?
- return false if cross_project?
-
- source_branch.exists?
+ !cross_project? && source_branch.exists?
end
def target_branch
@@ -61,9 +58,7 @@ module Gitlab
end
def target_branch_name
- @target_branch_name ||= begin
- target_branch_exists? ? target_branch_ref : target_branch_name_prefixed
- end
+ @target_branch_name ||= target_branch_exists? ? target_branch_ref : target_branch_name_prefixed
end
def target_branch_name_prefixed