summaryrefslogtreecommitdiff
path: root/lib/gitlab/github_import/representation/protected_branch.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/github_import/representation/protected_branch.rb')
-rw-r--r--lib/gitlab/github_import/representation/protected_branch.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/gitlab/github_import/representation/protected_branch.rb b/lib/gitlab/github_import/representation/protected_branch.rb
index b80b7cf1076..07a607ae70d 100644
--- a/lib/gitlab/github_import/representation/protected_branch.rb
+++ b/lib/gitlab/github_import/representation/protected_branch.rb
@@ -9,18 +9,22 @@ module Gitlab
attr_reader :attributes
- expose_attribute :id, :allow_force_pushes
+ expose_attribute :id, :allow_force_pushes, :required_conversation_resolution, :required_signatures,
+ :required_pull_request_reviews
# Builds a Branch Protection info from a GitHub API response.
# Resource structure details:
# https://docs.github.com/en/rest/branches/branch-protection#get-branch-protection
- # branch_protection - An instance of `Sawyer::Resource` containing the protection details.
+ # branch_protection - An instance of `Hash` containing the protection details.
def self.from_api_response(branch_protection, _additional_object_data = {})
- branch_name = branch_protection.url.match(%r{/branches/(\S{1,255})/protection$})[1]
+ branch_name = branch_protection[:url].match(%r{/branches/(\S{1,255})/protection$})[1]
hash = {
id: branch_name,
- allow_force_pushes: branch_protection.allow_force_pushes.enabled
+ allow_force_pushes: branch_protection.dig(:allow_force_pushes, :enabled),
+ required_conversation_resolution: branch_protection.dig(:required_conversation_resolution, :enabled),
+ required_signatures: branch_protection.dig(:required_signatures, :enabled),
+ required_pull_request_reviews: branch_protection[:required_pull_request_reviews].present?
}
new(hash)