Skip to content

Commit 15c5b99

Browse files
authored
Merge pull request #424 from raafaelima/add/hash-splat-operator-to-githubhelper
Add Hash-splat operator to GithubHelper methods
2 parents 04cfc68 + 48dc856 commit 15c5b99

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def self.run(params)
1515

1616
UI.user_error!("Milestone #{milestone_title} not found.") if milestone.nil?
1717

18-
github_helper.update_milestone(repository: repository, number: milestone[:number], options: { state: 'closed' })
18+
github_helper.update_milestone(repository: repository, number: milestone[:number], state: 'closed')
1919
end
2020

2121
def self.description

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/actions/common/setbranchprotection_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.set_branch_protection(repository: repository, branch: branch_name, options: branch_prot)
16+
github_helper.set_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/actions/common/setfrozentag_action.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def self.run(params)
2929
end
3030

3131
UI.message("New milestone: #{mile_title}")
32-
github_helper.update_milestone(repository: repository, number: milestone[:number], options: { title: mile_title })
32+
github_helper.update_milestone(repository: repository, number: milestone[:number], title: mile_title)
3333
end
3434

3535
def self.is_frozen(milestone)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def comment_on_pr(project_slug:, pr_number:, body:, reuse_identifier: SecureRand
189189
# @return [Milestone] A single milestone object
190190
# @see http://developer.github.com/v3/issues/milestones/#update-a-milestone
191191
#
192-
def update_milestone(repository:, number:, options:)
192+
def update_milestone(repository:, number:, **options)
193193
client.update_milestone(repository, number, options)
194194
end
195195

@@ -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

@@ -211,7 +211,7 @@ def remove_branch_protection(repository:, branch:, options:)
211211
# @param options [Hash] A customizable set of options.
212212
# @see https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection
213213
#
214-
def set_branch_protection(repository:, branch:, options:)
214+
def set_branch_protection(repository:, branch:, **options)
215215
client.protect_branch(repository, branch, options)
216216
end
217217

0 commit comments

Comments
 (0)