1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-02-02 15:09:33 -05:00

chore: golang lint

This commit is contained in:
Jason Song 2022-11-26 22:12:52 +08:00
parent bfe0fc1533
commit ef4b3673dd
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5
10 changed files with 15 additions and 16 deletions

View File

@ -16,14 +16,14 @@ import (
type RunJobList []*RunJob type RunJobList []*RunJob
func (jobs RunJobList) GetRunIDs() []int64 { func (jobs RunJobList) GetRunIDs() []int64 {
var runIDsMap = make(map[int64]struct{}) runIDsMap := make(map[int64]struct{})
for _, j := range jobs { for _, j := range jobs {
if j.RunID == 0 { if j.RunID == 0 {
continue continue
} }
runIDsMap[j.RunID] = struct{}{} runIDsMap[j.RunID] = struct{}{}
} }
var runIDs = make([]int64, 0, len(runIDsMap)) runIDs := make([]int64, 0, len(runIDsMap))
for runID := range runIDsMap { for runID := range runIDsMap {
runIDs = append(runIDs, runID) runIDs = append(runIDs, runID)
} }

View File

@ -16,14 +16,14 @@ import (
type TaskList []*Task type TaskList []*Task
func (tasks TaskList) GetJobIDs() []int64 { func (tasks TaskList) GetJobIDs() []int64 {
var jobIDsMap = make(map[int64]struct{}) jobIDsMap := make(map[int64]struct{})
for _, t := range tasks { for _, t := range tasks {
if t.JobID == 0 { if t.JobID == 0 {
continue continue
} }
jobIDsMap[t.JobID] = struct{}{} jobIDsMap[t.JobID] = struct{}{}
} }
var jobIDs = make([]int64, 0, len(jobIDsMap)) jobIDs := make([]int64, 0, len(jobIDsMap))
for jobID := range jobIDsMap { for jobID := range jobIDsMap {
jobIDs = append(jobIDs, jobID) jobIDs = append(jobIDs, jobID)
} }

View File

@ -13,8 +13,9 @@ import (
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/models/unittest"
_ "github.com/mattn/go-sqlite3"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
_ "github.com/mattn/go-sqlite3"
) )
func changeDefaultFileBlockSize(n int64) (restore func()) { func changeDefaultFileBlockSize(n int64) (restore func()) {

View File

@ -444,7 +444,6 @@ var migrations = []Migration{
// v235 -> v236 // v235 -> v236
NewMigration("Add index for access_token", v1_19.AddIndexForAccessToken), NewMigration("Add index for access_token", v1_19.AddIndexForAccessToken),
// in dev // in dev
NewMigration("Add bots tables", addBotTables), NewMigration("Add bots tables", addBotTables),
} }

View File

@ -57,7 +57,7 @@ func WriteLogs(ctx context.Context, filename string, offset int64, rows []*runne
return ns, nil return ns, nil
} }
func ReadLogs(ctx context.Context, inStorage bool, filename string, offset int64, limit int64) ([]*runnerv1.LogRow, error) { func ReadLogs(ctx context.Context, inStorage bool, filename string, offset, limit int64) ([]*runnerv1.LogRow, error) {
f, err := openLogs(ctx, inStorage, filename) f, err := openLogs(ctx, inStorage, filename)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -180,7 +180,7 @@ func (a *botsNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *user_m
} }
func (a *botsNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, func (a *botsNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue,
addedLabels []*issues_model.Label, removedLabels []*issues_model.Label, _, _ []*issues_model.Label,
) { ) {
var err error var err error
if err = issue.LoadRepo(ctx); err != nil { if err = issue.LoadRepo(ctx); err != nil {
@ -288,7 +288,7 @@ func (a *botsNotifier) NotifyRenameRepository(ctx context.Context, doer *user_mo
func (a *botsNotifier) NotifyTransferRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldOwnerName string) { func (a *botsNotifier) NotifyTransferRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldOwnerName string) {
} }
func (a *botsNotifier) NotifyCreateRepository(ctx context.Context, doer *user_model.User, u *user_model.User, repo *repo_model.Repository) { func (a *botsNotifier) NotifyCreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) {
if err := notify(repo, doer, repo.DefaultBranch, if err := notify(repo, doer, repo.DefaultBranch,
webhook.HookEventRepository, webhook.HookEventRepository,
&api.RepositoryPayload{ &api.RepositoryPayload{

View File

@ -20,7 +20,6 @@ import (
// RunnersList render common runners list page // RunnersList render common runners list page
func RunnersList(ctx *context.Context, tplName base.TplName, opts bots_model.FindRunnerOptions) { func RunnersList(ctx *context.Context, tplName base.TplName, opts bots_model.FindRunnerOptions) {
count, err := bots_model.CountRunners(opts) count, err := bots_model.CountRunners(opts)
if err != nil { if err != nil {
ctx.ServerError("AdminRunners", err) ctx.ServerError("AdminRunners", err)
@ -65,7 +64,7 @@ func RunnersList(ctx *context.Context, tplName base.TplName, opts bots_model.Fin
} }
// RunnerDetails render runner details page // RunnerDetails render runner details page
func RunnerDetails(ctx *context.Context, tplName base.TplName, page int, runnerID int64, ownerID int64, repoID int64) { func RunnerDetails(ctx *context.Context, tplName base.TplName, page int, runnerID, ownerID, repoID int64) {
runner, err := bots_model.GetRunnerByID(runnerID) runner, err := bots_model.GetRunnerByID(runnerID)
if err != nil { if err != nil {
ctx.ServerError("GetRunnerByID", err) ctx.ServerError("GetRunnerByID", err)
@ -117,7 +116,7 @@ func RunnerDetails(ctx *context.Context, tplName base.TplName, page int, runnerI
} }
// RunnerDetailsEditPost response for edit runner details // RunnerDetailsEditPost response for edit runner details
func RunnerDetailsEditPost(ctx *context.Context, runnerID int64, ownerID int64, repoID int64, redirectTo string) { func RunnerDetailsEditPost(ctx *context.Context, runnerID, ownerID, repoID int64, redirectTo string) {
runner, err := bots_model.GetRunnerByID(runnerID) runner, err := bots_model.GetRunnerByID(runnerID)
if err != nil { if err != nil {
log.Warn("RunnerDetailsEditPost.GetRunnerByID failed: %v, url: %s", err, ctx.Req.URL) log.Warn("RunnerDetailsEditPost.GetRunnerByID failed: %v, url: %s", err, ctx.Req.URL)
@ -162,7 +161,8 @@ func RunnerResetRegistrationToken(ctx *context.Context, ownerID, repoID int64, r
// RunnerDeletePost response for deleting a runner // RunnerDeletePost response for deleting a runner
func RunnerDeletePost(ctx *context.Context, runnerID int64, func RunnerDeletePost(ctx *context.Context, runnerID int64,
successRedirectTo, failedRedirectTo string) { successRedirectTo, failedRedirectTo string,
) {
runner, err := bots_model.GetRunnerByID(runnerID) runner, err := bots_model.GetRunnerByID(runnerID)
if err != nil { if err != nil {
log.Warn("DeleteRunnerPost.GetRunnerByID failed: %v, url: %s", err, ctx.Req.URL) log.Warn("DeleteRunnerPost.GetRunnerByID failed: %v, url: %s", err, ctx.Req.URL)

View File

@ -967,7 +967,6 @@ func RegisterRoutes(m *web.Route) {
m.Post("/{runnerid}/delete", repo.RunnerDeletePost) m.Post("/{runnerid}/delete", repo.RunnerDeletePost)
m.Get("/reset_registration_token", repo.ResetRunnerRegistrationToken) m.Get("/reset_registration_token", repo.ResetRunnerRegistrationToken)
}) })
}, func(ctx *context.Context) { }, func(ctx *context.Context) {
ctx.Data["PageIsSettings"] = true ctx.Data["PageIsSettings"] = true
ctx.Data["LFSStartServer"] = setting.LFS.StartServer ctx.Data["LFSStartServer"] = setting.LFS.StartServer

View File

@ -16,7 +16,7 @@
</div> </div>
</div> </div>
<div class="issue-item-right"> <div class="issue-item-right">
<div>{{ TimeSinceUnix .Updated $.locale }}</div> <div>{{TimeSinceUnix .Updated $.locale}}</div>
<div>{{.TakeTime}}</div> <div>{{.TakeTime}}</div>
</div> </div>
</li> </li>

View File

@ -183,7 +183,7 @@
</a> </a>
{{end}} {{end}}
{{ if and (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}} {{if and (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}}
<a class="{{if .PageIsBots}}active{{end}} item" href="{{.RepoLink}}/bots"> <a class="{{if .PageIsBots}}active{{end}} item" href="{{.RepoLink}}/bots">
{{svg "octicon-play"}} {{.locale.Tr "repo.bots"}} {{svg "octicon-play"}} {{.locale.Tr "repo.bots"}}
{{if .Repository.NumOpenRuns}} {{if .Repository.NumOpenRuns}}