Create branch protection api doesn't honor enable_force_push or enable_force_push_allowlist #14172

Closed
opened 2025-11-02 11:05:11 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @lissom on GitHub (Feb 21, 2025).

Description

        data = {
            "rule_name": "master,release/**",
            "enable_force_push": True,
            "enable_force_push_allowlist": True,
            "force_push_allowlist_teams": ["General"],
            "required_approvals": 1,
            "priority": 10,
        }
        url = f"{GITEA_API_URL}/api/v1/repos/{org_name}/{repo_name}/branch_protections"
        response = requests.post(url, headers=HEADERS, data=json.dumps(data))

Looking at the repo in the UI or with a GET call, enable_force_push is completely disabled.

Using the UI, this works.

Gitea Version

1.23.4

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

2.40.1

Operating System

Linux

How are you running Gitea?

Downloaded gitea from the github link.

Database

None

Originally created by @lissom on GitHub (Feb 21, 2025). ### Description data = { "rule_name": "master,release/**", "enable_force_push": True, "enable_force_push_allowlist": True, "force_push_allowlist_teams": ["General"], "required_approvals": 1, "priority": 10, } url = f"{GITEA_API_URL}/api/v1/repos/{org_name}/{repo_name}/branch_protections" response = requests.post(url, headers=HEADERS, data=json.dumps(data)) Looking at the repo in the UI or with a GET call, enable_force_push is completely disabled. Using the UI, this works. ### Gitea Version 1.23.4 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.40.1 ### Operating System Linux ### How are you running Gitea? Downloaded gitea from the github link. ### Database None
GiteaMirror added the topic/apiissue/needs-feedbacktype/bug labels 2025-11-02 11:05:11 -06:00
Author
Owner

@lunny commented on GitHub (Feb 27, 2025):

You need to enable push first.

"enable_push": True,

Documentation is missed.

@lunny commented on GitHub (Feb 27, 2025): You need to enable `push` first. ``` "enable_push": True, ``` Documentation is missed.
Author
Owner

@lissom commented on GitHub (Feb 27, 2025):

Thank you, that was it. It's non-obvious that disabled pushes would disable a forced push, but a reasonable choice. I guess web response don't really allow warnings.

@lissom commented on GitHub (Feb 27, 2025): Thank you, that was it. It's non-obvious that disabled pushes would disable a forced push, but a reasonable choice. I guess web response don't really allow warnings.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14172