Class: Gitlab::LegacyGithubImport::PullRequestFormatter
- Inherits:
-
IssuableFormatter
- Object
- BaseFormatter
- IssuableFormatter
- Gitlab::LegacyGithubImport::PullRequestFormatter
- Defined in:
- lib/gitlab/legacy_github_import/pull_request_formatter.rb
Instance Attribute Summary
Attributes inherited from BaseFormatter
#client, #formatter, #project, #raw_data
Instance Method Summary collapse
- #attributes ⇒ Object
- #cross_project? ⇒ Boolean
- #opened? ⇒ Boolean
- #project_association ⇒ Object
- #source_branch ⇒ Object
- #source_branch_exists? ⇒ Boolean
- #source_branch_name ⇒ Object
- #source_branch_name_prefixed ⇒ Object
- #target_branch ⇒ Object
- #target_branch_name ⇒ Object
- #target_branch_name_prefixed ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from IssuableFormatter
Methods inherited from BaseFormatter
Constructor Details
This class inherits a constructor from Gitlab::LegacyGithubImport::BaseFormatter
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: , assignee_id: assignee_id, created_at: raw_data[:created_at], updated_at: raw_data[:updated_at], imported: true } 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_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 |
#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 |