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 <mark@glines.org>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/626
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
Reviewed-by: delvh <dev.lh@web.de>
Co-authored-by: infinoid <infinoid@noreply.gitea.com>
Co-committed-by: infinoid <infinoid@noreply.gitea.com>
This commit is contained in:
infinoid 2023-08-01 16:26:41 +00:00 committed by John Olheiser
parent 93cfc320cf
commit ae1583a7be
1 changed files with 5 additions and 0 deletions

View File

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