Class: Gitlab::GithubImport::Settings
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Settings
- Defined in:
- lib/gitlab/github_import/settings.rb
Constant Summary collapse
- OPTIONAL_STAGES =
{ single_endpoint_notes_import: { label: 'Use alternative comments import method', selected: false, details: <<-TEXT.split("\n").map(&:strip).join(' ') The default method can skip some comments in large projects because of limitations of the GitHub API. TEXT }, attachments_import: { label: 'Import Markdown attachments (links)', selected: false, details: <<-TEXT.split("\n").map(&:strip).join(' ') Import Markdown attachments (links) from repository comments, release posts, issue descriptions, and pull request descriptions. These can include images, text, or binary attachments. If not imported, links in Markdown to attachments break after you remove the attachments from GitHub. TEXT }, collaborators_import: { label: 'Import collaborators', selected: true, details: <<-TEXT.split("\n").map(&:strip).join(' ') Import direct repository collaborators who are not outside collaborators. Imported collaborators who aren't members of the group you imported the project into consume seats on your GitLab instance. TEXT } }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #disabled?(stage_name) ⇒ Boolean
- #enabled?(stage_name) ⇒ Boolean
-
#initialize(project) ⇒ Settings
constructor
A new instance of Settings.
- #map_to_personal_namespace_owner? ⇒ Boolean
- #user_mapping_enabled? ⇒ Boolean
- #write(user_settings) ⇒ Object
Constructor Details
#initialize(project) ⇒ Settings
Returns a new instance of Settings.
44 45 46 |
# File 'lib/gitlab/github_import/settings.rb', line 44 def initialize(project) @project = project end |
Class Method Details
.stages_array(_current_user) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gitlab/github_import/settings.rb', line 33 def self.stages_array(_current_user) OPTIONAL_STAGES.map do |stage_name, data| { name: stage_name.to_s, label: s_(format("GitHubImport|%{text}", text: data[:label])), selected: data[:selected], details: s_(format("GitHubImport|%{text}", text: data[:details])) } end end |
Instance Method Details
#disabled?(stage_name) ⇒ Boolean
70 71 72 |
# File 'lib/gitlab/github_import/settings.rb', line 70 def disabled?(stage_name) !enabled?(stage_name) end |
#enabled?(stage_name) ⇒ Boolean
66 67 68 |
# File 'lib/gitlab/github_import/settings.rb', line 66 def enabled?(stage_name) project.import_data&.data&.dig('optional_stages', stage_name.to_s) || false end |
#map_to_personal_namespace_owner? ⇒ Boolean
78 79 80 |
# File 'lib/gitlab/github_import/settings.rb', line 78 def map_to_personal_namespace_owner? project.root_ancestor.user_namespace? end |
#user_mapping_enabled? ⇒ Boolean
74 75 76 |
# File 'lib/gitlab/github_import/settings.rb', line 74 def user_mapping_enabled? project.import_data&.data&.dig('user_contribution_mapping_enabled') || false end |
#write(user_settings) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gitlab/github_import/settings.rb', line 48 def write(user_settings) user_settings = user_settings.to_h.with_indifferent_access optional_stages = fetch_stages_from_params(user_settings[:optional_stages]) import_data = project.build_or_assign_import_data( data: { optional_stages: optional_stages, timeout_strategy: user_settings[:timeout_strategy], user_contribution_mapping_enabled: true, pagination_limit: user_settings[:pagination_limit] }, credentials: project.import_data&.credentials ) import_data.save! end |