|
|
@ -675,7 +675,7 @@ func mustEnableWiki(ctx *context.APIContext) { |
|
|
|
|
|
|
|
|
|
|
|
func mustNotBeArchived(ctx *context.APIContext) { |
|
|
|
func mustNotBeArchived(ctx *context.APIContext) { |
|
|
|
if ctx.Repo.Repository.IsArchived { |
|
|
|
if ctx.Repo.Repository.IsArchived { |
|
|
|
ctx.NotFound() |
|
|
|
ctx.Error(http.StatusLocked, "RepoArchived", fmt.Errorf("%s is archived", ctx.Repo.Repository.LogString())) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1108,23 +1108,23 @@ func Routes() *web.Route { |
|
|
|
m.Group("/branches", func() { |
|
|
|
m.Group("/branches", func() { |
|
|
|
m.Get("", repo.ListBranches) |
|
|
|
m.Get("", repo.ListBranches) |
|
|
|
m.Get("/*", repo.GetBranch) |
|
|
|
m.Get("/*", repo.GetBranch) |
|
|
|
m.Delete("/*", reqToken(), reqRepoWriter(unit.TypeCode), repo.DeleteBranch) |
|
|
|
m.Delete("/*", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.DeleteBranch) |
|
|
|
m.Post("", reqToken(), reqRepoWriter(unit.TypeCode), bind(api.CreateBranchRepoOption{}), repo.CreateBranch) |
|
|
|
m.Post("", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, bind(api.CreateBranchRepoOption{}), repo.CreateBranch) |
|
|
|
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode)) |
|
|
|
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode)) |
|
|
|
m.Group("/branch_protections", func() { |
|
|
|
m.Group("/branch_protections", func() { |
|
|
|
m.Get("", repo.ListBranchProtections) |
|
|
|
m.Get("", repo.ListBranchProtections) |
|
|
|
m.Post("", bind(api.CreateBranchProtectionOption{}), repo.CreateBranchProtection) |
|
|
|
m.Post("", bind(api.CreateBranchProtectionOption{}), mustNotBeArchived, repo.CreateBranchProtection) |
|
|
|
m.Group("/{name}", func() { |
|
|
|
m.Group("/{name}", func() { |
|
|
|
m.Get("", repo.GetBranchProtection) |
|
|
|
m.Get("", repo.GetBranchProtection) |
|
|
|
m.Patch("", bind(api.EditBranchProtectionOption{}), repo.EditBranchProtection) |
|
|
|
m.Patch("", bind(api.EditBranchProtectionOption{}), mustNotBeArchived, repo.EditBranchProtection) |
|
|
|
m.Delete("", repo.DeleteBranchProtection) |
|
|
|
m.Delete("", repo.DeleteBranchProtection) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, reqToken(), reqAdmin()) |
|
|
|
}, reqToken(), reqAdmin()) |
|
|
|
m.Group("/tags", func() { |
|
|
|
m.Group("/tags", func() { |
|
|
|
m.Get("", repo.ListTags) |
|
|
|
m.Get("", repo.ListTags) |
|
|
|
m.Get("/*", repo.GetTag) |
|
|
|
m.Get("/*", repo.GetTag) |
|
|
|
m.Post("", reqToken(), reqRepoWriter(unit.TypeCode), bind(api.CreateTagOption{}), repo.CreateTag) |
|
|
|
m.Post("", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, bind(api.CreateTagOption{}), repo.CreateTag) |
|
|
|
m.Delete("/*", reqToken(), repo.DeleteTag) |
|
|
|
m.Delete("/*", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.DeleteTag) |
|
|
|
}, reqRepoReader(unit.TypeCode), context.ReferencesGitRepo(true)) |
|
|
|
}, reqRepoReader(unit.TypeCode), context.ReferencesGitRepo(true)) |
|
|
|
m.Group("/keys", func() { |
|
|
|
m.Group("/keys", func() { |
|
|
|
m.Combo("").Get(repo.ListDeployKeys). |
|
|
|
m.Combo("").Get(repo.ListDeployKeys). |
|
|
@ -1245,15 +1245,15 @@ func Routes() *web.Route { |
|
|
|
m.Get("/tags/{sha}", repo.GetAnnotatedTag) |
|
|
|
m.Get("/tags/{sha}", repo.GetAnnotatedTag) |
|
|
|
m.Get("/notes/{sha}", repo.GetNote) |
|
|
|
m.Get("/notes/{sha}", repo.GetNote) |
|
|
|
}, context.ReferencesGitRepo(true), reqRepoReader(unit.TypeCode)) |
|
|
|
}, context.ReferencesGitRepo(true), reqRepoReader(unit.TypeCode)) |
|
|
|
m.Post("/diffpatch", reqRepoWriter(unit.TypeCode), reqToken(), bind(api.ApplyDiffPatchFileOptions{}), repo.ApplyDiffPatch) |
|
|
|
m.Post("/diffpatch", reqRepoWriter(unit.TypeCode), reqToken(), bind(api.ApplyDiffPatchFileOptions{}), mustNotBeArchived, repo.ApplyDiffPatch) |
|
|
|
m.Group("/contents", func() { |
|
|
|
m.Group("/contents", func() { |
|
|
|
m.Get("", repo.GetContentsList) |
|
|
|
m.Get("", repo.GetContentsList) |
|
|
|
m.Post("", reqToken(), bind(api.ChangeFilesOptions{}), reqRepoBranchWriter, repo.ChangeFiles) |
|
|
|
m.Post("", reqToken(), bind(api.ChangeFilesOptions{}), reqRepoBranchWriter, mustNotBeArchived, repo.ChangeFiles) |
|
|
|
m.Get("/*", repo.GetContents) |
|
|
|
m.Get("/*", repo.GetContents) |
|
|
|
m.Group("/*", func() { |
|
|
|
m.Group("/*", func() { |
|
|
|
m.Post("", bind(api.CreateFileOptions{}), reqRepoBranchWriter, repo.CreateFile) |
|
|
|
m.Post("", bind(api.CreateFileOptions{}), reqRepoBranchWriter, mustNotBeArchived, repo.CreateFile) |
|
|
|
m.Put("", bind(api.UpdateFileOptions{}), reqRepoBranchWriter, repo.UpdateFile) |
|
|
|
m.Put("", bind(api.UpdateFileOptions{}), reqRepoBranchWriter, mustNotBeArchived, repo.UpdateFile) |
|
|
|
m.Delete("", bind(api.DeleteFileOptions{}), reqRepoBranchWriter, repo.DeleteFile) |
|
|
|
m.Delete("", bind(api.DeleteFileOptions{}), reqRepoBranchWriter, mustNotBeArchived, repo.DeleteFile) |
|
|
|
}, reqToken()) |
|
|
|
}, reqToken()) |
|
|
|
}, reqRepoReader(unit.TypeCode)) |
|
|
|
}, reqRepoReader(unit.TypeCode)) |
|
|
|
m.Get("/signing-key.gpg", misc.SigningKey) |
|
|
|
m.Get("/signing-key.gpg", misc.SigningKey) |
|
|
|