Class: Gitlab::GithubImport::Importer::ProtectedBranchImporter
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Importer::ProtectedBranchImporter
- Includes:
- Import::PlaceholderReferences::Pusher
- Defined in:
- lib/gitlab/github_import/importer/protected_branch_importer.rb
Constant Summary collapse
- GITHUB_DEFAULT_MERGE_ACCESS_LEVEL =
By default on GitHub, both developers and maintainers can merge a PR into the protected branch
Gitlab::Access::DEVELOPER
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(protected_branch, project, client) ⇒ ProtectedBranchImporter
constructor
protected_branch - An instance of
Gitlab::GithubImport::Representation::ProtectedBranch.
Methods included from Import::PlaceholderReferences::Pusher
#map_to_personal_namespace_owner?, #push_reference, #push_reference_with_composite_key, #push_references_by_ids, #user_mapping_enabled?
Constructor Details
#initialize(protected_branch, project, client) ⇒ ProtectedBranchImporter
protected_branch - An instance of
`Gitlab::GithubImport::Representation::ProtectedBranch`.
project - An instance of Project client - An instance of Gitlab::GithubImport::Client
19 20 21 22 23 24 25 |
# File 'lib/gitlab/github_import/importer/protected_branch_importer.rb', line 19 def initialize(protected_branch, project, client) @protected_branch = protected_branch @project = project @client = client @user_finder = GithubImport::UserFinder.new(project, client) @gitlab_user_id_to_github_user_id = {} end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
9 10 11 |
# File 'lib/gitlab/github_import/importer/protected_branch_importer.rb', line 9 def project @project end |
Instance Method Details
#execute ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gitlab/github_import/importer/protected_branch_importer.rb', line 27 def execute # The creator of the project is always allowed to create protected # branches, so we skip the authorization check in this service class. imported_protected_branch = ProtectedBranches::CreateService .new(project, project.creator, params) .execute(skip_authorization: true) update_project_settings if default_branch? # ProtectedBranches::CreateService can return the unpersisted ProtectedBranch. # Call `#validate!` to pass any validation errors to the error handling in ImportProtectedBranchWorker. imported_protected_branch.validate! imported_protected_branch.push_access_levels.each do |push_access_level| next unless push_access_level.user_id source_user_identifier = gitlab_user_id_to_github_user_id[push_access_level.user_id] push_reference(project, push_access_level, :user_id, source_user_identifier) end end |