forgejo/routers
Infinoid 86ee5b4b1b
PATCH branch-protection updates check list even when checks are disabled (#26351)
Fixes: #26333.

Previously, this endpoint only updates the `StatusCheckContexts` field
when `EnableStatusCheck==true`, which makes it impossible to clear the
array otherwise.

This patch uses slice `nil`-ness to decide whether to update the list of
checks. The field is ignored when either the client explicitly passes in
a null, or just omits the field from the json ([which causes
`json.Unmarshal` to leave the struct field
unchanged](https://go.dev/play/p/Z2XHOILuB1Q)). I think this is a better
measure of intent than whether the `EnableStatusCheck` flag was set,
because it matches the semantics of other field types.

Also adds a test case. I noticed that [`testAPIEditBranchProtection`
only checks the branch
name](c1c83dbaec/tests/integration/api_branch_test.go (L68))
and no other fields, so I added some extra `GET` calls and specific
checks to make sure the fields are changing properly.

I added those checks the existing integration test; is that the right
place for it?
2023-08-24 05:36:04 +00:00
..
api PATCH branch-protection updates check list even when checks are disabled (#26351) 2023-08-24 05:36:04 +00:00
common Start using template context function (#26254) 2023-08-08 01:22:47 +00:00
install Handle base64 decoding correctly to avoid panic (#26483) 2023-08-14 10:30:16 +00:00
private Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
utils
web Add member, collaborator, contributor, and first-time contributor roles and tooltips (#26658) 2023-08-24 13:06:17 +08:00
init.go Pre-register OAuth2 applications for git credential helpers (#26291) 2023-08-09 14:24:07 +02:00