diff --git a/models/bots/run.go b/models/bots/run.go index 66715bd647..7d7c99cec1 100644 --- a/models/bots/run.go +++ b/models/bots/run.go @@ -56,7 +56,7 @@ func (Run) TableName() string { } func (run *Run) HTMLURL() string { - return fmt.Sprintf("%s/builds/runs/%d", run.Repo.HTMLURL(), run.Index) + return fmt.Sprintf("%s/bots/runs/%d", run.Repo.HTMLURL(), run.Index) } // LoadAttributes load Repo TriggerUser if not loaded diff --git a/models/bots/task.go b/models/bots/task.go index 1178c2857d..dd83c66701 100644 --- a/models/bots/task.go +++ b/models/bots/task.go @@ -127,7 +127,7 @@ func (task *Task) GetBuildViewLink() string { if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil { return "" } - return task.Job.Run.Repo.Link() + "/builds/runs/" + strconv.FormatInt(task.ID, 10) + return task.Job.Run.Repo.Link() + "/bots/runs/" + strconv.FormatInt(task.ID, 10) } func (task *Task) GetCommitLink() string { diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go index c4090255cb..02c2d65ad2 100644 --- a/models/repo/repo_unit.go +++ b/models/repo/repo_unit.go @@ -175,7 +175,7 @@ func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) { r.Config = new(PullRequestsConfig) case unit.TypeIssues: r.Config = new(IssuesConfig) - case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects, unit.TypePackages, unit.TypeBuilds: + case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects, unit.TypePackages, unit.TypeBots: fallthrough default: r.Config = new(UnitConfig) diff --git a/models/unit/unit.go b/models/unit/unit.go index 672494be98..740af6c18f 100644 --- a/models/unit/unit.go +++ b/models/unit/unit.go @@ -28,7 +28,7 @@ const ( TypeExternalTracker // 7 ExternalTracker TypeProjects // 8 Kanban board TypePackages // 9 Packages - TypeBuilds // 10 Builds + TypeBots // 10 Bots ) // Value returns integer value for unit type @@ -56,8 +56,8 @@ func (u Type) String() string { return "TypeProjects" case TypePackages: return "TypePackages" - case TypeBuilds: - return "TypeBuilds" + case TypeBots: + return "TypeBots" } return fmt.Sprintf("Unknown Type %d", u) } @@ -81,7 +81,7 @@ var ( TypeExternalTracker, TypeProjects, TypePackages, - TypeBuilds, + TypeBots, } // DefaultRepoUnits contains the default unit types @@ -293,11 +293,11 @@ var ( perm.AccessModeRead, } - UnitBuilds = Unit{ - TypeBuilds, - "repo.builds", - "/builds", - "repo.builds.desc", + UnitBots = Unit{ + TypeBots, + "repo.bots", + "/bots", + "repo.bots.desc", 7, perm.AccessModeOwner, } @@ -313,7 +313,7 @@ var ( TypeExternalWiki: UnitExternalWiki, TypeProjects: UnitProjects, TypePackages: UnitPackages, - TypeBuilds: UnitBuilds, + TypeBots: UnitBots, } ) diff --git a/modules/bots/log.go b/modules/bots/log.go index 3a7497e379..072a770194 100644 --- a/modules/bots/log.go +++ b/modules/bots/log.go @@ -104,7 +104,7 @@ func TransferLogs(ctx context.Context, filename string) (func(), error) { } defer f.Close() - if _, err := storage.Builds.Save(filename, f, -1); err != nil { + if _, err := storage.Bots.Save(filename, f, -1); err != nil { return nil, fmt.Errorf("storage save %q: %w", filename, err) } return remove, nil @@ -119,7 +119,7 @@ func openLogs(ctx context.Context, inStorage bool, filename string) (io.ReadSeek } return f, nil } - f, err := storage.Builds.Open(filename) + f, err := storage.Bots.Open(filename) if err != nil { return nil, fmt.Errorf("storage open %q: %w", filename, err) } diff --git a/modules/context/context.go b/modules/context/context.go index 78d3472b67..babf042307 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -807,7 +807,7 @@ func Contexter(ctx context.Context) func(next http.Handler) http.Handler { ctx.Data["UnitIssuesGlobalDisabled"] = unit.TypeIssues.UnitGlobalDisabled() ctx.Data["UnitPullsGlobalDisabled"] = unit.TypePullRequests.UnitGlobalDisabled() ctx.Data["UnitProjectsGlobalDisabled"] = unit.TypeProjects.UnitGlobalDisabled() - ctx.Data["UnitBuildsGlobalDisabled"] = unit.TypeBuilds.UnitGlobalDisabled() + ctx.Data["UnitBotsGlobalDisabled"] = unit.TypeBots.UnitGlobalDisabled() ctx.Data["locale"] = locale ctx.Data["AllLangs"] = translation.AllLangs() diff --git a/modules/context/repo.go b/modules/context/repo.go index 5408991d72..d2da93127f 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -1043,7 +1043,7 @@ func UnitTypes() func(ctx *Context) { ctx.Data["UnitTypeExternalTracker"] = unit_model.TypeExternalTracker ctx.Data["UnitTypeProjects"] = unit_model.TypeProjects ctx.Data["UnitTypePackages"] = unit_model.TypePackages - ctx.Data["UnitTypeBuilds"] = unit_model.TypeBuilds + ctx.Data["UnitTypeBots"] = unit_model.TypeBots } } diff --git a/modules/notification/bots/bots.go b/modules/notification/bots/bots.go index 0c78d95afc..632c829685 100644 --- a/modules/notification/bots/bots.go +++ b/modules/notification/bots/bots.go @@ -45,12 +45,12 @@ func NewNotifier() base.Notifier { } func notify(repo *repo_model.Repository, doer *user_model.User, ref string, evt webhook.HookEventType, payload api.Payloader) error { - if unit.TypeBuilds.UnitGlobalDisabled() { + if unit.TypeBots.UnitGlobalDisabled() { return nil } if err := repo.LoadUnits(db.DefaultContext); err != nil { return fmt.Errorf("repo.LoadUnits: %w", err) - } else if !repo.UnitEnabled(unit.TypeBuilds) { + } else if !repo.UnitEnabled(unit.TypeBots) { return nil } diff --git a/modules/setting/bot.go b/modules/setting/bot.go index 417bc0a809..e7cda607ce 100644 --- a/modules/setting/bot.go +++ b/modules/setting/bot.go @@ -20,10 +20,10 @@ var ( } ) -func newBuilds() { +func newBots() { sec := Cfg.Section("bots") if err := sec.MapTo(&Bots); err != nil { - log.Fatal("Failed to map Builds settings: %v", err) + log.Fatal("Failed to map Bots settings: %v", err) } Bots.Storage = getStorage("bots_log", "", nil) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 8634866206..2189cf55cc 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -1079,7 +1079,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) { newPackages() - newBuilds() + newBots() if err = Cfg.Section("ui").MapTo(&UI); err != nil { log.Fatal("Failed to map UI settings: %v", err) diff --git a/modules/storage/storage.go b/modules/storage/storage.go index a261fc215c..def06c1386 100644 --- a/modules/storage/storage.go +++ b/modules/storage/storage.go @@ -127,8 +127,8 @@ var ( // Packages represents packages storage Packages ObjectStorage - // Builds represents builds storage - Builds ObjectStorage + // Bots represents bots storage + Bots ObjectStorage ) // Init init the stoarge @@ -200,6 +200,6 @@ func initPackages() (err error) { func initBots() (err error) { log.Info("Initialising Bots storage with type: %s", setting.Bots.Storage.Type) - Builds, err = NewStorage(setting.Bots.Storage.Type, &setting.Bots.Storage) + Bots, err = NewStorage(setting.Bots.Storage.Type, &setting.Bots.Storage) return err } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 04abab3a88..8086848db8 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1227,11 +1227,11 @@ projects.open = Open projects.close = Close projects.board.assigned_to = Assigned to -builds = Builds -builds.desc = Manage builds -builds.opened_by = opened %[1]s by %[2]s -builds.open_tab = %d Open -builds.closed_tab = %d Closed +bots = Bots +bots.desc = Manage bots +bots.opened_by = opened %[1]s by %[2]s +bots.open_tab = %d Open +bots.closed_tab = %d Closed issues.desc = Organize bug reports, tasks and milestones. issues.filter_assignees = Filter Assignee diff --git a/routers/web/repo/builds/builds.go b/routers/web/repo/bots/bots.go similarity index 81% rename from routers/web/repo/builds/builds.go rename to routers/web/repo/bots/bots.go index 7ae038fd57..95d6e322a7 100644 --- a/routers/web/repo/builds/builds.go +++ b/routers/web/repo/bots/bots.go @@ -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) } diff --git a/routers/web/repo/builds/view.go b/routers/web/repo/bots/view.go similarity index 97% rename from routers/web/repo/builds/view.go rename to routers/web/repo/bots/view.go index 1ba5e2977c..c2639a7281 100644 --- a/routers/web/repo/builds/view.go +++ b/routers/web/repo/bots/view.go @@ -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) } diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index 91cde89980..0df3af0634 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -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() { diff --git a/routers/web/web.go b/routers/web/web.go index f656a8d699..a492f2a80c 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -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("/"). diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 6652178cf8..361e764560 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -148,7 +148,7 @@ type RepoSettingForm struct { EnableProjects bool EnablePackages bool EnablePulls bool - EnableBuilds bool + EnableBots bool PullsIgnoreWhitespace bool PullsAllowMerge bool PullsAllowRebase bool diff --git a/templates/repo/builds/build_list.tmpl b/templates/repo/bots/build_list.tmpl similarity index 92% rename from templates/repo/builds/build_list.tmpl rename to templates/repo/bots/build_list.tmpl index f1a7009a04..596603acf1 100644 --- a/templates/repo/builds/build_list.tmpl +++ b/templates/repo/bots/build_list.tmpl @@ -1,8 +1,8 @@
- {{range .Builds}} + {{range .Runs}}
  • - {{template "repo/builds/status" .Status}} + {{template "repo/bots/status" .Status}}
    diff --git a/templates/repo/builds/list.tmpl b/templates/repo/bots/list.tmpl similarity index 93% rename from templates/repo/builds/list.tmpl rename to templates/repo/bots/list.tmpl index 0b99f17f17..8f59660ddb 100644 --- a/templates/repo/builds/list.tmpl +++ b/templates/repo/bots/list.tmpl @@ -16,12 +16,12 @@
    - {{template "repo/builds/openclose" .}} + {{template "repo/bots/openclose" .}}
    - {{template "repo/builds/openclose" .}} + {{template "repo/bots/openclose" .}}
    {{/* Ten wide does not cope well and makes the columns stack. @@ -41,7 +41,7 @@
    - {{template "repo/builds/build_list" .}} + {{template "repo/bots/build_list" .}}
  • diff --git a/templates/repo/builds/openclose.tmpl b/templates/repo/bots/openclose.tmpl similarity index 76% rename from templates/repo/builds/openclose.tmpl rename to templates/repo/bots/openclose.tmpl index 35ace3feb8..bb8c72707d 100644 --- a/templates/repo/builds/openclose.tmpl +++ b/templates/repo/bots/openclose.tmpl @@ -1,10 +1,10 @@ diff --git a/templates/repo/builds/status.tmpl b/templates/repo/bots/status.tmpl similarity index 100% rename from templates/repo/builds/status.tmpl rename to templates/repo/bots/status.tmpl diff --git a/templates/repo/builds/view.tmpl b/templates/repo/bots/view.tmpl similarity index 100% rename from templates/repo/builds/view.tmpl rename to templates/repo/bots/view.tmpl diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index c7e670ecd5..52a5ead893 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -183,9 +183,9 @@ {{end}} - {{ if and (not .UnitBuildsGlobalDisabled) (.Permission.CanRead $.UnitTypeBuilds)}} - - {{svg "octicon-play"}} {{.locale.Tr "repo.builds"}} + {{ if and (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}} + + {{svg "octicon-play"}} {{.locale.Tr "repo.bots"}} {{if .Repository.NumOpenRuns}} {{CountFmt .Repository.NumOpenRuns}} {{end}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index eb15717df3..06cb25854f 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -420,16 +420,16 @@ - {{$isBuildsEnabled := .Repository.UnitEnabled $.UnitTypeBuilds}} + {{$isBotsEnabled := .Repository.UnitEnabled $.UnitTypeBots}}
    - - {{if .UnitTypeBuilds.UnitGlobalDisabled}} + + {{if .UnitTypeBots.UnitGlobalDisabled}}
    {{else}}
    {{end}} - - + +