Class: Gitlab::LegacyGithubImport::PullRequestFormatter
Constant Summary
Import::UsernameMentionRewriter::MENTION_REGEX
Instance Attribute Summary
#client, #formatter, #project, #raw_data, #source_user_mapper
Instance Method Summary
collapse
#create!, #find_condition, #number
#update_username_mentions, #wrap_mentions_in_backticks
#create!, #create_record, #imported_from, #initialize, #push_placeholder_reference, #push_placeholder_references, #url
Instance Method Details
#attributes ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 9
def attributes
{
iid: number,
title: raw_data[:title],
description: description,
source_project: source_branch_project,
source_branch: source_branch_name,
source_branch_sha: source_branch_sha,
target_project: target_branch_project,
target_branch: target_branch_name,
target_branch_sha: target_branch_sha,
state: state,
milestone: milestone,
author_id: author_id,
assignee_id: assignee_id,
created_at: raw_data[:created_at],
updated_at: raw_data[:updated_at],
imported_from: imported_from
}
end
|
91
92
93
94
95
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 91
def contributing_assignee_formatters
{
user_id: assignee
}
end
|
85
86
87
88
89
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 85
def contributing_user_formatters
{
author_id: author
}
end
|
#cross_project? ⇒ Boolean
71
72
73
74
75
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 71
def cross_project?
return true if source_branch_repo.nil?
source_branch_repo[:id] != target_branch_repo[:id]
end
|
#opened? ⇒ Boolean
77
78
79
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 77
def opened?
state == 'opened'
end
|
#project_assignee_association ⇒ Object
81
82
83
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 81
def project_assignee_association
:merge_request_assignees
end
|
#project_association ⇒ Object
30
31
32
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 30
def project_association
:merge_requests
end
|
#source_branch ⇒ Object
38
39
40
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 38
def source_branch
@source_branch ||= BranchFormatter.new(project, raw_data[:head])
end
|
#source_branch_exists? ⇒ Boolean
55
56
57
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 55
def source_branch_exists?
!cross_project? && source_branch.exists?
end
|
#source_branch_name ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 42
def source_branch_name
@source_branch_name ||=
if cross_project? || !source_branch_exists?
source_branch_name_prefixed
else
source_branch_ref
end
end
|
#source_branch_name_prefixed ⇒ Object
51
52
53
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 51
def source_branch_name_prefixed
"gh-#{target_branch_short_sha}/#{number}/#{source_branch_user}/#{source_branch_ref}"
end
|
#target_branch ⇒ Object
59
60
61
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 59
def target_branch
@target_branch ||= BranchFormatter.new(project, raw_data[:base])
end
|
#target_branch_name ⇒ Object
63
64
65
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 63
def target_branch_name
@target_branch_name ||= target_branch_exists? ? target_branch_ref : target_branch_name_prefixed
end
|
#target_branch_name_prefixed ⇒ Object
67
68
69
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 67
def target_branch_name_prefixed
"gl-#{target_branch_short_sha}/#{number}/#{target_branch_user}/#{target_branch_ref}"
end
|
#target_branch_sha ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 97
def target_branch_sha
if raw_data[:merged] && raw_data[:merge_base].present?
raw_data[:merge_base]
else
target_branch.sha
end
end
|
#valid? ⇒ Boolean
34
35
36
|
# File 'lib/gitlab/legacy_github_import/pull_request_formatter.rb', line 34
def valid?
source_branch.valid? && target_branch.valid?
end
|