Skip to content

Commit 2455d5d

Browse files
committed
fix(protection): Resolves json unmarshal protection error
Currently when trying to load in protection an error is thrown due to a data structure mismatch resulting in errors: json: cannot unmarshal object into Go struct field Protection.lock_branch of type bool json: cannot unmarshal object into Go struct field Protection.allow_fork_syncing of type bool This is due to them using an enabled field which the current structure does not understand. This change introduces the relevant structure and has been tested locally. Signed-off-by: Jason Field <jason@avon-lea.co.uk>
1 parent 2b4d596 commit 2455d5d

3 files changed

Lines changed: 60 additions & 22 deletions

File tree

github/github-accessors.go

Lines changed: 26 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 22 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,18 @@ type Protection struct {
843843
AllowForcePushes *AllowForcePushes `json:"allow_force_pushes"`
844844
AllowDeletions *AllowDeletions `json:"allow_deletions"`
845845
RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"`
846-
// LockBranch represents if the branch is marked as read-only. If this is true, users will not be able to push to the branch.
847-
LockBranch *bool `json:"lock_branch,omitempty"`
848-
// AllowForkSyncing represents whether users can pull changes from upstream when the branch is locked.
849-
AllowForkSyncing *bool `json:"allow_fork_syncing,omitempty"`
846+
LockBranch *LockBranch `json:"lock_branch,omitempty"`
847+
AllowForkSyncing *AllowForkSyncing `json:"allow_fork_syncing,omitempty"`
848+
}
849+
850+
// LockBranch represents if the branch is marked as read-only. If this is true, users will not be able to push to the branch.
851+
type LockBranch struct {
852+
Enabled *bool `json:"enabled,omitempty"`
853+
}
854+
855+
// AllowForkSyncing represents whether users can pull changes from upstream when the branch is locked.
856+
type AllowForkSyncing struct {
857+
Enabled *bool `json:"enabled,omitempty"`
850858
}
851859

852860
// BranchProtectionRule represents the rule applied to a repositories branch.

0 commit comments

Comments
 (0)