From ae1583a7be18d68e3b7bd3b89a1a9b582da9b009 Mon Sep 17 00:00:00 2001 From: infinoid Date: Tue, 1 Aug 2023 16:26:41 +0000 Subject: [PATCH] Add missing fields to BranchProtection and related structs (#626) the `gitea.BranchProtection` struct is missing some fields which are present in the actual gitea API (and swagger). * BranchProtection.RuleName was added in gitea v1.19.0, via [PR #20825](https://github.com/go-gitea/gitea/pull/20825) * BranchProtection.UnprotectedFilePatterns was added in gitea v1.16.0, via [PR #16395](https://github.com/go-gitea/gitea/pull/16395) This PR adds those fields to the BranchProtection struct, and the related Create and Edit option structs, to match the structs [defined](https://github.com/go-gitea/gitea/blob/main/modules/structs/repo_branch.go#L27) on the gitea server side. Co-authored-by: Mark Glines Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/626 Reviewed-by: John Olheiser Reviewed-by: delvh Co-authored-by: infinoid Co-committed-by: infinoid --- gitea/repo_branch_protection.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gitea/repo_branch_protection.go b/gitea/repo_branch_protection.go index 22bd7b9..3196d03 100644 --- a/gitea/repo_branch_protection.go +++ b/gitea/repo_branch_protection.go @@ -15,6 +15,7 @@ import ( // BranchProtection represents a branch protection for a repository type BranchProtection struct { BranchName string `json:"branch_name"` + RuleName string `json:"rule_name"` EnablePush bool `json:"enable_push"` EnablePushWhitelist bool `json:"enable_push_whitelist"` PushWhitelistUsernames []string `json:"push_whitelist_usernames"` @@ -35,6 +36,7 @@ type BranchProtection struct { DismissStaleApprovals bool `json:"dismiss_stale_approvals"` RequireSignedCommits bool `json:"require_signed_commits"` ProtectedFilePatterns string `json:"protected_file_patterns"` + UnprotectedFilePatterns string `json:"unprotected_file_patterns"` Created time.Time `json:"created_at"` Updated time.Time `json:"updated_at"` } @@ -42,6 +44,7 @@ type BranchProtection struct { // CreateBranchProtectionOption options for creating a branch protection type CreateBranchProtectionOption struct { BranchName string `json:"branch_name"` + RuleName string `json:"rule_name"` EnablePush bool `json:"enable_push"` EnablePushWhitelist bool `json:"enable_push_whitelist"` PushWhitelistUsernames []string `json:"push_whitelist_usernames"` @@ -62,6 +65,7 @@ type CreateBranchProtectionOption struct { DismissStaleApprovals bool `json:"dismiss_stale_approvals"` RequireSignedCommits bool `json:"require_signed_commits"` ProtectedFilePatterns string `json:"protected_file_patterns"` + UnprotectedFilePatterns string `json:"unprotected_file_patterns"` } // EditBranchProtectionOption options for editing a branch protection @@ -86,6 +90,7 @@ type EditBranchProtectionOption struct { DismissStaleApprovals *bool `json:"dismiss_stale_approvals"` RequireSignedCommits *bool `json:"require_signed_commits"` ProtectedFilePatterns *string `json:"protected_file_patterns"` + UnprotectedFilePatterns *string `json:"unprotected_file_patterns"` } // ListBranchProtectionsOptions list branch protection options