Minor refactor
This commit is contained in:
parent
c8273ba858
commit
3c75ee2823
2 changed files with 7 additions and 12 deletions
|
@ -15,8 +15,8 @@ module Gitlab
|
||||||
raw_data.user&.login || 'unknown'
|
raw_data.user&.login || 'unknown'
|
||||||
end
|
end
|
||||||
|
|
||||||
def short_sha(length = 7)
|
def short_sha
|
||||||
sha.to_s[0..length]
|
Commit.truncate_sha(sha)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -37,13 +37,12 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_branch_name
|
def source_branch_name
|
||||||
@source_branch_name ||= begin
|
@source_branch_name ||=
|
||||||
if cross_project?
|
if cross_project? || !source_branch_exists?
|
||||||
source_branch_name_prefixed
|
source_branch_name_prefixed
|
||||||
else
|
else
|
||||||
source_branch_exists? ? source_branch_ref : source_branch_name_prefixed
|
source_branch_ref
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_branch_name_prefixed
|
def source_branch_name_prefixed
|
||||||
|
@ -51,9 +50,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_branch_exists?
|
def source_branch_exists?
|
||||||
return false if cross_project?
|
!cross_project? && source_branch.exists?
|
||||||
|
|
||||||
source_branch.exists?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_branch
|
def target_branch
|
||||||
|
@ -61,9 +58,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_branch_name
|
def target_branch_name
|
||||||
@target_branch_name ||= begin
|
@target_branch_name ||= target_branch_exists? ? target_branch_ref : target_branch_name_prefixed
|
||||||
target_branch_exists? ? target_branch_ref : target_branch_name_prefixed
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_branch_name_prefixed
|
def target_branch_name_prefixed
|
||||||
|
|
Loading…
Reference in a new issue