blob: 372c6b2e8a08ab9b3e217a291005383b726393d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# frozen_string_literal: true
module Gitlab
module LegacyGithubImport
class BranchFormatter < BaseFormatter
def repo
raw_data[:repo]
end
def sha
raw_data[:sha]
end
def ref
raw_data[:ref]
end
def exists?
branch_exists? && commit_exists?
end
def valid?
sha.present? && ref.present?
end
def user
raw_data.dig(:user, :login) || 'unknown'
end
def short_sha
Commit.truncate_sha(sha)
end
private
def branch_exists?
project.repository.branch_exists?(ref)
end
def commit_exists?
project.repository.branch_names_contains(sha).include?(ref)
end
def short_id
sha.to_s[0..7]
end
end
end
end
|