Class: Fastlane::Actions::RemoveBranchProtectionAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



50
51
52
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb', line 50

def self.authors
  ['Automattic']
end

.available_optionsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb', line 34

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :repository,
                                 env_name: 'GHHELPER_REPOSITORY',
                                 description: 'The remote path of the GH repository on which we work',
                                 optional: false,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :branch,
                                 env_name: 'GHHELPER_BRANCH',
                                 description: 'The branch to unprotect',
                                 optional: false,
                                 type: String),
    Fastlane::Helper::GithubHelper.github_token_config_item,
  ]
end

.descriptionObject



22
23
24
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb', line 22

def self.description
  'Removes the protection settings for the specified branch'
end

.detailsObject



26
27
28
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb', line 26

def self.details
  description
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb', line 54

def self.is_supported?(platform)
  true
end

.return_valueObject



30
31
32
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb', line 30

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb', line 7

def self.run(params)
  repository = params[:repository]
  branch_name = params[:branch]

  github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
  github_helper.remove_branch_protection(
    repository: repository,
    branch: branch_name
  )
rescue Octokit::NotFound
  UI.user_error!("Branch `#{branch_name}` of repository `#{repository}` was not found.")
rescue Octokit::BranchNotProtected
  UI.message("Note: Branch `#{branch_name}` was not protected in the first place.")
end