提交 3c75ee28 编写于 作者: G Gabriel Mazetto

Minor refactor

上级 c8273ba8
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册