Skip to content

Commit 9369d0d

Browse files
committed
GithubHelper: Add Hash-Conversion operator to remove_branch_protection
The change was done to make the method signature cleaner to use the options parameter as named parameters
1 parent 1542e02 commit 9369d0d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/removebranchprotection_action.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ def self.run(params)
88
repository = params[:repository]
99
branch_name = params[:branch]
1010

11-
branch_prot = {}
1211
branch_url = "https://api.github.com/repos/#{repository}/branches/#{branch_name}"
13-
branch_prot[:restrictions] = { url: "#{branch_url}/protection/restrictions", users_url: "#{branch_url}/protection/restrictions/users", teams_url: "#{branch_url}/protection/restrictions/teams", users: [], teams: [] }
14-
branch_prot[:enforce_admins] = nil
15-
branch_prot[:required_pull_request_reviews] = { url: "#{branch_url}/protection/required_pull_request_reviews", dismiss_stale_reviews: false, require_code_owner_reviews: false }
12+
restrictions = { url: "#{branch_url}/protection/restrictions", users_url: "#{branch_url}/protection/restrictions/users", teams_url: "#{branch_url}/protection/restrictions/teams", users: [], teams: [] }
13+
required_pull_request_reviews = { url: "#{branch_url}/protection/required_pull_request_reviews", dismiss_stale_reviews: false, require_code_owner_reviews: false }
1614

1715
github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
18-
github_helper.remove_branch_protection(repository: repository, branch: branch_name, options: branch_prot)
16+
github_helper.remove_branch_protection(
17+
repository: repository,
18+
branch: branch_name,
19+
restrictions: restrictions,
20+
enforce_admins: nil,
21+
required_pull_request_reviews: required_pull_request_reviews
22+
)
1923
end
2024

2125
def self.description

lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def update_milestone(repository:, number:, **options)
200200
# @param [Hash] options A customizable set of options.
201201
# @see https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection
202202
#
203-
def remove_branch_protection(repository:, branch:, options:)
203+
def remove_branch_protection(repository:, branch:, **options)
204204
client.unprotect_branch(repository, branch, options)
205205
end
206206

0 commit comments

Comments
 (0)