API endpoint to configure default branch and protected branches is missing #1249

Closed
opened 2025-11-02 03:54:05 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @nblock on GitHub (Nov 15, 2017).

  • Gitea version: 1.2.3

Description

Gitea allows to configure the default branch and protected branches via GITEA_URL/org/repo/settings/branches but I could not find an API alternative in the local Swagger documentation.

Originally created by @nblock on GitHub (Nov 15, 2017). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version: 1.2.3 ## Description Gitea allows to configure the default branch and protected branches via GITEA_URL/org/repo/settings/branches but I could not find an API alternative in the local Swagger documentation.
GiteaMirror added the type/featureissue/confirmedmodifies/api labels 2025-11-02 03:54:05 -06:00
Author
Owner

@davidlt commented on GitHub (May 29, 2018):

I am also looking for such API especially since 1.4.1 set random default branch on git push --mirror ( https://github.com/go-gitea/gitea/issues/3913 ). Thus I wanted to use API to reset it back to master.

@davidlt commented on GitHub (May 29, 2018): I am also looking for such API especially since 1.4.1 set random default branch on `git push --mirror` ( https://github.com/go-gitea/gitea/issues/3913 ). Thus I wanted to use API to reset it back to `master`.
Author
Owner

@davidlt commented on GitHub (Jun 2, 2018):

Looks like GitHub supports it at least since 2012: https://developer.github.com/changes/2012-10-24-set-default-branch/

It's done via PATCH /repos/:owner/:repo : https://developer.github.com/v3/repos/#edit

@davidlt commented on GitHub (Jun 2, 2018): Looks like GitHub supports it at least since 2012: https://developer.github.com/changes/2012-10-24-set-default-branch/ It's done via `PATCH /repos/:owner/:repo` : https://developer.github.com/v3/repos/#edit
Author
Owner

@jonasfranz commented on GitHub (Jun 2, 2018):

Currently you cannot update repository at all.

@jonasfranz commented on GitHub (Jun 2, 2018): Currently you cannot update repository at all.
Author
Owner

@jonasfranz commented on GitHub (Jun 2, 2018):

Getting the DefaultBranch is support.

@jonasfranz commented on GitHub (Jun 2, 2018): Getting the DefaultBranch is support.
Author
Owner

@sankethpb commented on GitHub (Dec 11, 2018):

any updates on this? Is this already supported in Gitea 1.5.x and above?

@sankethpb commented on GitHub (Dec 11, 2018): any updates on this? Is this already supported in Gitea 1.5.x and above?
Author
Owner

@lunny commented on GitHub (Dec 12, 2018):

@sankethpb nobody are working on this.

@lunny commented on GitHub (Dec 12, 2018): @sankethpb nobody are working on this.
Author
Owner

@stale[bot] commented on GitHub (Feb 10, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Feb 10, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@davidsvantesson commented on GitHub (Oct 26, 2019):

If wildcard protected branches (#2529) get implemented it is necessary to consider how this affect the API.

I would suggest two API endpoints:

  • ...{repo}/branches(/{branch}) corresponds to actual branches and only gives some limited information on effective branch protection (e.g. if branch is protected, number of approvals required, name of effective branch protection)
  • ...{repo}/branch_protections(/{branch}) where branch is a configured branch protection (specific branch or wildcard). To edit a branch protection this endpoint should be used.
@davidsvantesson commented on GitHub (Oct 26, 2019): If wildcard protected branches (#2529) get implemented it is necessary to consider how this affect the API. I would suggest two API endpoints: - **...{repo}/branches(/{branch})** corresponds to actual branches and only gives some limited information on **effective** branch protection (e.g. if branch is protected, number of approvals required, name of effective branch protection) - **...{repo}/branch_protections(/{branch})** where branch is a configured branch protection (specific branch or wildcard). To edit a branch protection this endpoint should be used.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1249