Class: Gitlab::GithubImport::Importer::ProtectedBranchImporter

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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`



17
18
19
20
21
22
# File 'lib/gitlab/github_import/importer/protected_branch_importer.rb', line 17

def initialize(protected_branch, project, client)
  @protected_branch = protected_branch
  @project = project
  @client = client
  @user_finder = GithubImport::UserFinder.new(project, client)
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'lib/gitlab/github_import/importer/protected_branch_importer.rb', line 7

def project
  @project
end

Instance Method Details

#executeObject



24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/github_import/importer/protected_branch_importer.rb', line 24

def execute
  # The creator of the project is always allowed to create protected
  # branches, so we skip the authorization check in this service class.
  ProtectedBranches::CreateService
    .new(project, project.creator, params)
    .execute(skip_authorization: true)

  update_project_settings if default_branch?
end