mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
rename builds -> bots
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package builds
|
||||
package bots
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@@ -18,28 +18,28 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
tplListBuilds base.TplName = "repo/builds/list"
|
||||
tplViewBuild base.TplName = "repo/builds/view"
|
||||
tplListBots base.TplName = "repo/bots/list"
|
||||
tplViewBuild base.TplName = "repo/bots/view"
|
||||
)
|
||||
|
||||
// MustEnableBuilds check if builds are enabled in settings
|
||||
func MustEnableBuilds(ctx *context.Context) {
|
||||
if unit.TypeBuilds.UnitGlobalDisabled() {
|
||||
ctx.NotFound("EnableTypeBuilds", nil)
|
||||
// MustEnableBots check if bots are enabled in settings
|
||||
func MustEnableBots(ctx *context.Context) {
|
||||
if unit.TypeBots.UnitGlobalDisabled() {
|
||||
ctx.NotFound("MustEnableBots", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository != nil {
|
||||
if !ctx.Repo.CanRead(unit.TypeBuilds) {
|
||||
ctx.NotFound("MustEnableBuilds", nil)
|
||||
if !ctx.Repo.CanRead(unit.TypeBots) {
|
||||
ctx.NotFound("MustEnableBots", nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func List(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.builds")
|
||||
ctx.Data["PageIsBuilds"] = true
|
||||
ctx.Data["Title"] = ctx.Tr("repo.bots")
|
||||
ctx.Data["PageIsBots"] = true
|
||||
|
||||
defaultBranch, err := ctx.Repo.GitRepo.GetDefaultBranch()
|
||||
if err != nil {
|
||||
@@ -118,11 +118,11 @@ func List(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Builds"] = runs
|
||||
ctx.Data["Runs"] = runs
|
||||
|
||||
pager := context.NewPagination(int(total), opts.PageSize, opts.Page, 5)
|
||||
pager.SetDefaultParams(ctx)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(http.StatusOK, tplListBuilds)
|
||||
ctx.HTML(http.StatusOK, tplListBots)
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
package builds
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package bots
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -18,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func View(ctx *context_module.Context) {
|
||||
ctx.Data["PageIsBuilds"] = true
|
||||
ctx.Data["PageIsBots"] = true
|
||||
runIndex := ctx.ParamsInt64("run")
|
||||
jobIndex := ctx.ParamsInt64("job")
|
||||
ctx.Data["RunIndex"] = runIndex
|
||||
@@ -31,7 +35,6 @@ func View(ctx *context_module.Context) {
|
||||
run := job.Run
|
||||
ctx.Data["Build"] = run
|
||||
|
||||
// ctx.Data["Build"] = &bots_model.Run{Title: "test", Index: 123, Status: bots_model.StatusRunning}
|
||||
ctx.HTML(http.StatusOK, tplViewBuild)
|
||||
}
|
||||
|
||||
@@ -490,13 +490,13 @@ func SettingsPost(ctx *context.Context) {
|
||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePackages)
|
||||
}
|
||||
|
||||
if form.EnableBuilds && !unit_model.TypeBuilds.UnitGlobalDisabled() {
|
||||
if form.EnableBots && !unit_model.TypeBots.UnitGlobalDisabled() {
|
||||
units = append(units, repo_model.RepoUnit{
|
||||
RepoID: repo.ID,
|
||||
Type: unit_model.TypeBuilds,
|
||||
Type: unit_model.TypeBots,
|
||||
})
|
||||
} else if !unit_model.TypeBuilds.UnitGlobalDisabled() {
|
||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeBuilds)
|
||||
} else if !unit_model.TypeBots.UnitGlobalDisabled() {
|
||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeBots)
|
||||
}
|
||||
|
||||
if form.EnablePulls && !unit_model.TypePullRequests.UnitGlobalDisabled() {
|
||||
|
||||
+11
-11
@@ -36,7 +36,7 @@ import (
|
||||
"code.gitea.io/gitea/routers/web/misc"
|
||||
"code.gitea.io/gitea/routers/web/org"
|
||||
"code.gitea.io/gitea/routers/web/repo"
|
||||
"code.gitea.io/gitea/routers/web/repo/builds"
|
||||
"code.gitea.io/gitea/routers/web/repo/bots"
|
||||
"code.gitea.io/gitea/routers/web/user"
|
||||
user_setting "code.gitea.io/gitea/routers/web/user/setting"
|
||||
"code.gitea.io/gitea/routers/web/user/setting/security"
|
||||
@@ -679,7 +679,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
reqRepoIssuesOrPullsReader := context.RequireRepoReaderOr(unit.TypeIssues, unit.TypePullRequests)
|
||||
reqRepoProjectsReader := context.RequireRepoReader(unit.TypeProjects)
|
||||
reqRepoProjectsWriter := context.RequireRepoWriter(unit.TypeProjects)
|
||||
reqRepoBuildsReader := context.RequireRepoReader(unit.TypeBuilds)
|
||||
reqRepoBotsReader := context.RequireRepoReader(unit.TypeBots)
|
||||
|
||||
reqPackageAccess := func(accessMode perm.AccessMode) func(ctx *context.Context) {
|
||||
return func(ctx *context.Context) {
|
||||
@@ -1212,22 +1212,22 @@ func RegisterRoutes(m *web.Route) {
|
||||
}, reqRepoProjectsWriter, context.RepoMustNotBeArchived())
|
||||
}, reqRepoProjectsReader, repo.MustEnableProjects)
|
||||
|
||||
m.Group("/builds", func() {
|
||||
m.Get("", builds.List)
|
||||
m.Group("/bots", func() {
|
||||
m.Get("", bots.List)
|
||||
|
||||
m.Group("/runs/{run}", func() {
|
||||
m.Combo("").
|
||||
Get(builds.View).
|
||||
Post(bindIgnErr(builds.ViewRequest{}), builds.ViewPost)
|
||||
Get(bots.View).
|
||||
Post(bindIgnErr(bots.ViewRequest{}), bots.ViewPost)
|
||||
m.Group("/jobs/{job}", func() {
|
||||
m.Combo("").
|
||||
Get(builds.View).
|
||||
Post(bindIgnErr(builds.ViewRequest{}), builds.ViewPost)
|
||||
m.Post("/rerun", builds.Rerun)
|
||||
Get(bots.View).
|
||||
Post(bindIgnErr(bots.ViewRequest{}), bots.ViewPost)
|
||||
m.Post("/rerun", bots.Rerun)
|
||||
})
|
||||
m.Post("/cancel", builds.Cancel)
|
||||
m.Post("/cancel", bots.Cancel)
|
||||
})
|
||||
}, reqRepoBuildsReader, builds.MustEnableBuilds)
|
||||
}, reqRepoBotsReader, bots.MustEnableBots)
|
||||
|
||||
m.Group("/wiki", func() {
|
||||
m.Combo("/").
|
||||
|
||||
Reference in New Issue
Block a user