0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-02-08 18:19:55 +01:00
gitea/routers/api/v1/repo
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
..
avatar.go Add API for changing Avatars (#25369) 2023-06-29 23:22:55 +00:00
blob.go
branch.go PATCH branch-protection updates check list even when checks are disabled (#26351) 2023-08-24 05:36:04 +00:00
collaborators.go
commits.go
file.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
fork.go
git_hook.go
git_ref.go
hook_test.go
hook.go
issue_attachment.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
issue_comment_attachment.go For API attachments, use API URL (#25639) 2023-07-10 09:31:19 +00:00
issue_comment.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
issue_dependency.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
issue_label.go Refactor and enhance issue indexer to support both searching, filtering and paging (#26012) 2023-07-31 06:28:53 +00:00
issue_pin.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
issue_reaction.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
issue_stopwatch.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
issue_subscription.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
issue_tracked_time.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
issue.go Return empty when searching issues with no repos (#26545) 2023-08-17 12:42:17 -05:00
key.go
label.go Allow to archive labels (#26478) 2023-08-14 11:56:14 +02:00
language.go
main_test.go
migrate.go
milestone.go
mirror.go Use correct response code in push mirror creation response in v1_json.tmpl (#25476) 2023-06-28 22:00:19 +00:00
notes.go
patch.go Sync branches into databases (#22743) 2023-06-29 10:03:20 +00:00
pull_review.go
pull.go
release_attachment.go For API attachments, use API URL (#25639) 2023-07-10 09:31:19 +00:00
release_tags.go For API attachments, use API URL (#25639) 2023-07-10 09:31:19 +00:00
release.go For API attachments, use API URL (#25639) 2023-07-10 09:31:19 +00:00
repo_test.go
repo.go Support copy protected branch from template repository (#25889) 2023-07-21 12:32:47 +08:00
star.go
status.go
subscriber.go
tag.go
teams.go
topic.go Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
transfer.go
tree.go
wiki.go Introduce ctx.PathParamRaw to avoid incorrect unescaping (#26392) 2023-08-09 14:57:45 +08:00