-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add API endpoints to update/delete protected branch #7093
Conversation
Thanks for PR :) The CI is currently failing due to needing a rebase on the latest commit of master. I think additional routes for the API are needing for these methods, as well as swagger definitions. |
Codecov Report
@@ Coverage Diff @@
## master #7093 +/- ##
==========================================
- Coverage 41.8% 41.12% -0.68%
==========================================
Files 496 469 -27
Lines 65586 63604 -1982
==========================================
- Hits 27416 26159 -1257
+ Misses 34654 34027 -627
+ Partials 3516 3418 -98
Continue to review full report at Codecov.
|
85243c9
to
9c4976a
Compare
Routes and swagger definitions have been added. |
protectBranch, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, ctx.Params(":branch")) | ||
if err != nil { | ||
if !git.IsErrBranchNotExist(err) { | ||
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchBy", err) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xorm will not give an error if there is no row in the database, but an empty object.
You need to handle:
- If there is no protected branch, but the branch exist (create protectBranch with default values / protection:false )
- If the branch doesn't exist. (404)
if !git.IsErrBranchNotExist(err) { | ||
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchBy", err) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same problem as above with xorm.
If the protected branch does not exist, you need to check if the branch exist (or give 404)
if !git.IsErrBranchNotExist(err) { | ||
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchBy", err) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same problem as above with xorm. Maybe ok to give 404 directly if protected branch doesn't exist.
@@ -9115,6 +9243,44 @@ | |||
}, | |||
"x-go-package": "code.gitea.io/gitea/modules/structs" | |||
}, | |||
"ProtectBranchForm": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit problematic to reuse the same structure for API from documentation point of view. How do I know the format of XWhiteListTeams and XWhiteListUsers? Preferably they should be arrays. At least they should change name to XWhiteListTeamIDs and XWhiteListUserIDs
Commit *PayloadCommit `json:"commit"` | ||
Name string `json:"name"` | ||
Commit *PayloadCommit `json:"commit"` | ||
Protected bool `json:"protected"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need more details about the branch protection settings but not only a bool
.
I think this one can be moved to 1.12, no chance for this release. I hope either this one or my new PR can get into next release. |
This pull request 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 months. Thank you for your contributions. |
This one can be closed. |
Fix #2922