Class: Fastlane::Actions::CopyBranchProtectionAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::CopyBranchProtectionAction
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
71 72 73 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb', line 71 def self. ['Automattic'] end |
.available_options ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb', line 50 def self. [ 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: :from_branch, env_name: 'GHHELPER_FROM_BRANCH', description: 'The branch to copy the protection settings from', optional: false, type: String), FastlaneCore::ConfigItem.new(key: :to_branch, env_name: 'GHHELPER_TO_BRANCH', description: 'The branch to copy the protection settings to', optional: false, type: String), Fastlane::Helper::GithubHelper.github_token_config_item, ] end |
.description ⇒ Object
38 39 40 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb', line 38 def self.description 'Copies the branch protection settings of one branch onto another branch' end |
.details ⇒ Object
42 43 44 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb', line 42 def self.details description end |
.is_supported?(platform) ⇒ Boolean
75 76 77 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb', line 75 def self.is_supported?(platform) true end |
.return_value ⇒ Object
46 47 48 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb', line 46 def self.return_value 'The hash corresponding to the response returned by the API request, and containing the applied protection settings' end |
.run(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb', line 7 def self.run(params) repository = params[:repository] from_branch = params[:from_branch] to_branch = params[:to_branch] github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token]) response = begin github_helper.get_branch_protection( repository: repository, branch: from_branch ) rescue Octokit::NotFound UI.user_error!("Branch `#{from_branch}` of repository `#{repository}` was not found.") end UI.user_error!("Branch `#{from_branch}` does not have any branch protection set up.") if response.nil? settings = Fastlane::Helper::GithubHelper.branch_protection_api_response_to_normalized_hash(response) response = begin github_helper.set_branch_protection( repository: repository, branch: to_branch, **settings ) rescue Octokit::NotFound UI.user_error!("Branch `#{to_branch}` of repository `#{repository}` was not found.") end Fastlane::Helper::GithubHelper.branch_protection_api_response_to_normalized_hash(response) end |