mirror of
https://github.com/go-gitea/gitea
synced 2025-07-03 09:07:19 +00:00
Updates to the API for archived repos (#27149)
This commit is contained in:
@ -117,17 +117,13 @@ func DeleteBranch(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
ctx.Error(http.StatusNotFound, "", "Git Repository is empty.")
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository.IsArchived {
|
||||
ctx.Error(http.StatusForbidden, "", "Git Repository is archived.")
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository.IsMirror {
|
||||
ctx.Error(http.StatusForbidden, "", "Git Repository is a mirror.")
|
||||
return
|
||||
@ -157,10 +153,6 @@ func DeleteBranch(ctx *context.APIContext) {
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository.IsArchived {
|
||||
ctx.Error(http.StatusForbidden, "IsArchived", fmt.Errorf("can not delete branch of an archived repository"))
|
||||
return
|
||||
}
|
||||
if ctx.Repo.Repository.IsMirror {
|
||||
ctx.Error(http.StatusForbidden, "IsMirrored", fmt.Errorf("can not delete branch of an mirror repository"))
|
||||
return
|
||||
@ -216,17 +208,14 @@ func CreateBranch(ctx *context.APIContext) {
|
||||
// description: The old branch does not exist.
|
||||
// "409":
|
||||
// description: The branch with the same name already exists.
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
ctx.Error(http.StatusNotFound, "", "Git Repository is empty.")
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository.IsArchived {
|
||||
ctx.Error(http.StatusForbidden, "", "Git Repository is archived.")
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository.IsMirror {
|
||||
ctx.Error(http.StatusForbidden, "", "Git Repository is a mirror.")
|
||||
return
|
||||
@ -519,6 +508,8 @@ func CreateBranchProtection(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
form := web.GetForm(ctx).(*api.CreateBranchProtectionOption)
|
||||
repo := ctx.Repo.Repository
|
||||
@ -727,6 +718,8 @@ func EditBranchProtection(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
form := web.GetForm(ctx).(*api.EditBranchProtectionOption)
|
||||
repo := ctx.Repo.Repository
|
||||
bpName := ctx.Params(":name")
|
||||
@ -1004,7 +997,7 @@ func DeleteBranchProtection(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := git_model.DeleteProtectedBranch(ctx, ctx.Repo.Repository.ID, bp.ID); err != nil {
|
||||
if err := git_model.DeleteProtectedBranch(ctx, ctx.Repo.Repository, bp.ID); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteProtectedBranch", err)
|
||||
return
|
||||
}
|
||||
|
@ -450,6 +450,8 @@ func ChangeFiles(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
apiOpts := web.GetForm(ctx).(*api.ChangeFilesOptions)
|
||||
|
||||
@ -550,6 +552,8 @@ func CreateFile(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
apiOpts := web.GetForm(ctx).(*api.CreateFileOptions)
|
||||
|
||||
@ -646,6 +650,8 @@ func UpdateFile(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
apiOpts := web.GetForm(ctx).(*api.UpdateFileOptions)
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "RepoIsEmpty", fmt.Errorf("repo is empty"))
|
||||
@ -806,6 +812,8 @@ func DeleteFile(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
apiOpts := web.GetForm(ctx).(*api.DeleteFileOptions)
|
||||
if !canWriteFiles(ctx, apiOpts.BranchName) {
|
||||
|
@ -631,6 +631,8 @@ func CreateIssue(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/error"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
form := web.GetForm(ctx).(*api.CreateIssueOption)
|
||||
var deadlineUnix timeutil.TimeStamp
|
||||
if form.Deadline != nil && ctx.Repo.CanWrite(unit.TypeIssues) {
|
||||
|
@ -153,6 +153,8 @@ func CreateIssueAttachment(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
issue := getIssueFromContext(ctx)
|
||||
if issue == nil {
|
||||
@ -238,6 +240,8 @@ func EditIssueAttachment(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/Attachment"
|
||||
// "404":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
attachment := getIssueAttachmentSafeWrite(ctx)
|
||||
if attachment == nil {
|
||||
@ -292,6 +296,8 @@ func DeleteIssueAttachment(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
attachment := getIssueAttachmentSafeWrite(ctx)
|
||||
if attachment == nil {
|
||||
|
@ -358,6 +358,8 @@ func CreateIssueComment(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
form := web.GetForm(ctx).(*api.CreateIssueCommentOption)
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
@ -486,7 +488,8 @@ func EditIssueComment(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
form := web.GetForm(ctx).(*api.EditIssueCommentOption)
|
||||
editIssueComment(ctx, *form)
|
||||
}
|
||||
|
@ -156,6 +156,8 @@ func CreateIssueCommentAttachment(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
// Check if comment exists and load comment
|
||||
comment := getIssueCommentSafe(ctx)
|
||||
@ -245,7 +247,8 @@ func EditIssueCommentAttachment(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/Attachment"
|
||||
// "404":
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
attach := getIssueCommentAttachmentSafeWrite(ctx)
|
||||
if attach == nil {
|
||||
return
|
||||
@ -297,7 +300,8 @@ func DeleteIssueCommentAttachment(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
attach := getIssueCommentAttachmentSafeWrite(ctx)
|
||||
if attach == nil {
|
||||
return
|
||||
|
@ -187,6 +187,8 @@ func CreateIssueDependency(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/Issue"
|
||||
// "404":
|
||||
// description: the issue does not exist
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
// We want to make <:index> depend on <Form>, i.e. <:index> is the target
|
||||
target := getParamsIssue(ctx)
|
||||
@ -246,6 +248,8 @@ func RemoveIssueDependency(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/Issue"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
// We want to make <:index> depend on <Form>, i.e. <:index> is the target
|
||||
target := getParamsIssue(ctx)
|
||||
|
@ -47,6 +47,8 @@ func ApplyDiffPatch(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/FileResponse"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
apiOpts := web.GetForm(ctx).(*api.ApplyDiffPatchFileOptions)
|
||||
|
||||
opts := &files.ApplyDiffPatchOptions{
|
||||
|
@ -282,6 +282,8 @@ func CreatePullRequest(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/error"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
form := *web.GetForm(ctx).(*api.CreatePullRequestOption)
|
||||
if form.Head == form.Base {
|
||||
@ -741,6 +743,8 @@ func MergePullRequest(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/empty"
|
||||
// "409":
|
||||
// "$ref": "#/responses/error"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
form := web.GetForm(ctx).(*forms.MergePullRequestForm)
|
||||
|
||||
@ -1196,6 +1200,8 @@ func CancelScheduledAutoMerge(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
pullIndex := ctx.ParamsInt64(":index")
|
||||
pull, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, pullIndex)
|
||||
|
@ -184,6 +184,8 @@ func CreateTag(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/empty"
|
||||
// "409":
|
||||
// "$ref": "#/responses/conflict"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
form := web.GetForm(ctx).(*api.CreateTagOption)
|
||||
|
||||
// If target is not provided use default branch
|
||||
@ -251,6 +253,8 @@ func DeleteTag(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/empty"
|
||||
// "409":
|
||||
// "$ref": "#/responses/conflict"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
tagName := ctx.Params("*")
|
||||
|
||||
tag, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
|
@ -52,6 +52,8 @@ func NewWikiPage(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
form := web.GetForm(ctx).(*api.CreateWikiPageOptions)
|
||||
|
||||
@ -128,6 +130,8 @@ func EditWikiPage(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
form := web.GetForm(ctx).(*api.CreateWikiPageOptions)
|
||||
|
||||
@ -234,6 +238,8 @@ func DeleteWikiPage(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "423":
|
||||
// "$ref": "#/responses/repoArchivedError"
|
||||
|
||||
wikiName := wiki_service.WebPathFromRequest(ctx.PathParamRaw(":pageName"))
|
||||
|
||||
|
Reference in New Issue
Block a user