mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02:00
rename builds -> bots
This commit is contained in:
parent
c61ac24c1c
commit
2ecb59c092
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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("/").
|
||||
|
@ -148,7 +148,7 @@ type RepoSettingForm struct {
|
||||
EnableProjects bool
|
||||
EnablePackages bool
|
||||
EnablePulls bool
|
||||
EnableBuilds bool
|
||||
EnableBots bool
|
||||
PullsIgnoreWhitespace bool
|
||||
PullsAllowMerge bool
|
||||
PullsAllowRebase bool
|
||||
|
@ -1,8 +1,8 @@
|
||||
<div class="issue list">
|
||||
{{range .Builds}}
|
||||
{{range .Runs}}
|
||||
<li class="item df py-3">
|
||||
<div class="issue-item-left df">
|
||||
{{template "repo/builds/status" .Status}}
|
||||
{{template "repo/bots/status" .Status}}
|
||||
</div>
|
||||
<div class="issue-item-main f1 fc df">
|
||||
<div class="issue-item-top-row">
|
@ -16,12 +16,12 @@
|
||||
<div class="twelve wide column content">
|
||||
<div id="issue-filters" class="ui stackable grid">
|
||||
<div class="six wide column">
|
||||
{{template "repo/builds/openclose" .}}
|
||||
{{template "repo/bots/openclose" .}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="issue-actions" class="ui stackable grid hide">
|
||||
<div class="six wide column">
|
||||
{{template "repo/builds/openclose" .}}
|
||||
{{template "repo/bots/openclose" .}}
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
{{/* Ten wide does not cope well and makes the columns stack.
|
||||
@ -41,7 +41,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{template "repo/builds/build_list" .}}
|
||||
{{template "repo/bots/build_list" .}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,10 +1,10 @@
|
||||
<div class="ui compact tiny menu">
|
||||
<a class="{{if not .IsShowClosed}}active{{end}} item" href="{{$.Link}}?workflow={{.CurWorkflow}}&state=open">
|
||||
{{svg "octicon-issue-opened" 16 "mr-3"}}
|
||||
{{.locale.Tr "repo.builds.open_tab" $.NumOpenRuns}}
|
||||
{{.locale.Tr "repo.bots.open_tab" $.NumOpenRuns}}
|
||||
</a>
|
||||
<a class="{{if .IsShowClosed}}active{{end}} item" href="{{$.Link}}?workflow={{.CurWorkflow}}&state=closed">
|
||||
{{svg "octicon-issue-closed" 16 "mr-3"}}
|
||||
{{.locale.Tr "repo.builds.closed_tab" $.NumClosedRuns}}
|
||||
{{.locale.Tr "repo.bots.closed_tab" $.NumClosedRuns}}
|
||||
</a>
|
||||
</div>
|
@ -183,9 +183,9 @@
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
{{ if and (not .UnitBuildsGlobalDisabled) (.Permission.CanRead $.UnitTypeBuilds)}}
|
||||
<a class="{{if .PageIsBuilds}}active{{end}} item" href="{{.RepoLink}}/builds">
|
||||
{{svg "octicon-play"}} {{.locale.Tr "repo.builds"}}
|
||||
{{ if and (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}}
|
||||
<a class="{{if .PageIsBots}}active{{end}} item" href="{{.RepoLink}}/bots">
|
||||
{{svg "octicon-play"}} {{.locale.Tr "repo.bots"}}
|
||||
{{if .Repository.NumOpenRuns}}
|
||||
<span class="ui blue small label">{{CountFmt .Repository.NumOpenRuns}}</span>
|
||||
{{end}}
|
||||
|
@ -420,16 +420,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{$isBuildsEnabled := .Repository.UnitEnabled $.UnitTypeBuilds}}
|
||||
{{$isBotsEnabled := .Repository.UnitEnabled $.UnitTypeBots}}
|
||||
<div class="inline field">
|
||||
<label>{{.locale.Tr "repo.builds"}}</label>
|
||||
{{if .UnitTypeBuilds.UnitGlobalDisabled}}
|
||||
<label>{{.locale.Tr "repo.bots"}}</label>
|
||||
{{if .UnitTypeBots.UnitGlobalDisabled}}
|
||||
<div class="ui checkbox tooltip disabled" data-content="{{.locale.Tr "repo.unit_disabled"}}">
|
||||
{{else}}
|
||||
<div class="ui checkbox">
|
||||
{{end}}
|
||||
<input class="enable-system" name="enable_builds" type="checkbox" {{if $isBuildsEnabled}}checked{{end}}>
|
||||
<label>{{.locale.Tr "repo.settings.builds_desc"}}</label>
|
||||
<input class="enable-system" name="enable_bots" type="checkbox" {{if $isBotsEnabled}}checked{{end}}>
|
||||
<label>{{.locale.Tr "repo.settings.bots_desc"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user