Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.run(params)

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

github_helper.update_milestone(repository: repository, number: milestone[:number], options: { state: 'closed' })
github_helper.update_milestone(repository: repository, number: milestone[:number], state: 'closed')
end

def self.description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ def self.run(params)
repository = params[:repository]
branch_name = params[:branch]

branch_prot = {}
branch_url = "https://api.github.com/repos/#{repository}/branches/#{branch_name}"
branch_prot[:restrictions] = { url: "#{branch_url}/protection/restrictions", users_url: "#{branch_url}/protection/restrictions/users", teams_url: "#{branch_url}/protection/restrictions/teams", users: [], teams: [] }
branch_prot[:enforce_admins] = nil
branch_prot[:required_pull_request_reviews] = { url: "#{branch_url}/protection/required_pull_request_reviews", dismiss_stale_reviews: false, require_code_owner_reviews: false }
restrictions = { url: "#{branch_url}/protection/restrictions", users_url: "#{branch_url}/protection/restrictions/users", teams_url: "#{branch_url}/protection/restrictions/teams", users: [], teams: [] }
required_pull_request_reviews = { url: "#{branch_url}/protection/required_pull_request_reviews", dismiss_stale_reviews: false, require_code_owner_reviews: false }

github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
github_helper.remove_branch_protection(repository: repository, branch: branch_name, options: branch_prot)
github_helper.remove_branch_protection(
repository: repository,
branch: branch_name,
restrictions: restrictions,
enforce_admins: nil,
required_pull_request_reviews: required_pull_request_reviews
)
end

def self.description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ def self.run(params)
repository = params[:repository]
branch_name = params[:branch]

branch_prot = {}
branch_url = "https://api.github.com/repos/#{repository}/branches/#{branch_name}"
branch_prot[:restrictions] = { url: "#{branch_url}/protection/restrictions", users_url: "#{branch_url}/protection/restrictions/users", teams_url: "#{branch_url}/protection/restrictions/teams", users: [], teams: [] }
branch_prot[:enforce_admins] = nil
branch_prot[:required_pull_request_reviews] = { url: "#{branch_url}/protection/required_pull_request_reviews", dismiss_stale_reviews: false, require_code_owner_reviews: false }
restrictions = { url: "#{branch_url}/protection/restrictions", users_url: "#{branch_url}/protection/restrictions/users", teams_url: "#{branch_url}/protection/restrictions/teams", users: [], teams: [] }
required_pull_request_reviews = { url: "#{branch_url}/protection/required_pull_request_reviews", dismiss_stale_reviews: false, require_code_owner_reviews: false }

github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
github_helper.set_branch_protection(repository: repository, branch: branch_name, options: branch_prot)
github_helper.set_branch_protection(
repository: repository,
branch: branch_name,
restrictions: restrictions,
enforce_admins: nil,
required_pull_request_reviews: required_pull_request_reviews
)
end

def self.description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.run(params)
end

UI.message("New milestone: #{mile_title}")
github_helper.update_milestone(repository: repository, number: milestone[:number], options: { title: mile_title })
github_helper.update_milestone(repository: repository, number: milestone[:number], title: mile_title)
end

def self.is_frozen(milestone)
Expand Down
6 changes: 3 additions & 3 deletions lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def comment_on_pr(project_slug:, pr_number:, body:, reuse_identifier: SecureRand
# @return [Milestone] A single milestone object
# @see http://developer.github.com/v3/issues/milestones/#update-a-milestone
#
def update_milestone(repository:, number:, options:)
def update_milestone(repository:, number:, **options)
client.update_milestone(repository, number, options)
end

Expand All @@ -200,7 +200,7 @@ def update_milestone(repository:, number:, options:)
# @param [Hash] options A customizable set of options.
# @see https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection
#
def remove_branch_protection(repository:, branch:, options:)
def remove_branch_protection(repository:, branch:, **options)
client.unprotect_branch(repository, branch, options)
end

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

Expand Down