Skip to content

Commit 513c506

Browse files
committed
Fix lint
1 parent 0820930 commit 513c506

File tree

2 files changed

+41
-43
lines changed

2 files changed

+41
-43
lines changed

modules/context/repo.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"strings"
1515

1616
"code.gitea.io/gitea/models"
17-
"code.gitea.io/gitea/models/unit"
1817
unit_model "code.gitea.io/gitea/models/unit"
1918
"code.gitea.io/gitea/modules/cache"
2019
"code.gitea.io/gitea/modules/git"
@@ -74,12 +73,12 @@ type Repository struct {
7473

7574
// CanEnableEditor returns true if repository is editable and user has proper access level.
7675
func (r *Repository) CanEnableEditor() bool {
77-
return r.Permission.CanWrite(unit.TypeCode) && r.Repository.CanEnableEditor() && r.IsViewBranch && !r.Repository.IsArchived
76+
return r.Permission.CanWrite(unit_model.TypeCode) && r.Repository.CanEnableEditor() && r.IsViewBranch && !r.Repository.IsArchived
7877
}
7978

8079
// CanCreateBranch returns true if repository is editable and user has proper access level.
8180
func (r *Repository) CanCreateBranch() bool {
82-
return r.Permission.CanWrite(unit.TypeCode) && r.Repository.CanCreateBranch()
81+
return r.Permission.CanWrite(unit_model.TypeCode) && r.Repository.CanCreateBranch()
8382
}
8483

8584
// RepoMustNotBeArchived checks if a repo is archived
@@ -278,7 +277,7 @@ func RetrieveTemplateRepo(ctx *Context, repo *models.Repository) {
278277
return
279278
}
280279

281-
if !perm.CanRead(unit.TypeCode) {
280+
if !perm.CanRead(unit_model.TypeCode) {
282281
repo.TemplateID = 0
283282
}
284283
}
@@ -465,7 +464,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
465464

466465
unit, err := ctx.Repo.Repository.GetUnit(unit_model.TypeExternalTracker)
467466
if err == nil {
468-
ctx.Data["RepoExternalIssuesLink"] = unit.ExternalTrackerConfig().ExternalTrackerURL
467+
ctx.Data["RepoExternalIssuesLink"] = unit_model.ExternalTrackerConfig().ExternalTrackerURL
469468
}
470469

471470
ctx.Data["NumTags"], err = models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{
@@ -899,14 +898,14 @@ func GitHookService() func(ctx *Context) {
899898
// UnitTypes returns a middleware to set unit types to context variables.
900899
func UnitTypes() func(ctx *Context) {
901900
return func(ctx *Context) {
902-
ctx.Data["UnitTypeCode"] = unit.TypeCode
903-
ctx.Data["UnitTypeIssues"] = unit.TypeIssues
904-
ctx.Data["UnitTypePullRequests"] = unit.TypePullRequests
905-
ctx.Data["UnitTypeReleases"] = unit.TypeReleases
906-
ctx.Data["UnitTypeUncyclo"] = unit.TypeUncyclo
907-
ctx.Data["UnitTypeExternalUncyclo"] = unit.TypeExternalUncyclo
908-
ctx.Data["UnitTypeExternalTracker"] = unit.TypeExternalTracker
909-
ctx.Data["UnitTypeProjects"] = unit.TypeProjects
901+
ctx.Data["UnitTypeCode"] = unit_model.TypeCode
902+
ctx.Data["UnitTypeIssues"] = unit_model.TypeIssues
903+
ctx.Data["UnitTypePullRequests"] = unit_model.TypePullRequests
904+
ctx.Data["UnitTypeReleases"] = unit_model.TypeReleases
905+
ctx.Data["UnitTypeUncyclo"] = unit_model.TypeUncyclo
906+
ctx.Data["UnitTypeExternalUncyclo"] = unit_model.TypeExternalUncyclo
907+
ctx.Data["UnitTypeExternalTracker"] = unit_model.TypeExternalTracker
908+
ctx.Data["UnitTypeProjects"] = unit_model.TypeProjects
910909
}
911910
}
912911

routers/web/repo/setting.go

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
"code.gitea.io/gitea/models"
1818
"code.gitea.io/gitea/models/db"
19-
"code.gitea.io/gitea/models/unit"
2019
unit_model "code.gitea.io/gitea/models/unit"
2120
"code.gitea.io/gitea/modules/base"
2221
"code.gitea.io/gitea/modules/context"
@@ -339,7 +338,7 @@ func SettingsPost(ctx *context.Context) {
339338
case "advanced":
340339
var repoChanged bool
341340
var units []models.RepoUnit
342-
var deleteUnitTypes []unit.Type
341+
var deleteUnitTypes []unit_model.Type
343342

344343
// This section doesn't require repo_name/RepoName to be set in the form, don't show it
345344
// as an error on the UI for this action
@@ -350,7 +349,7 @@ func SettingsPost(ctx *context.Context) {
350349
repoChanged = true
351350
}
352351

353-
if form.EnableUncyclo && form.EnableExternalUncyclo && !unit.TypeExternalUncyclo.UnitGlobalDisabled() {
352+
if form.EnableUncyclo && form.EnableExternalUncyclo && !unit_model.TypeExternalUncyclo.UnitGlobalDisabled() {
354353
if !validation.IsValidExternalURL(form.ExternalUncycloURL) {
355354
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))
356355
ctx.Redirect(repo.Link() + "/settings")
@@ -359,29 +358,29 @@ func SettingsPost(ctx *context.Context) {
359358

360359
units = append(units, models.RepoUnit{
361360
RepoID: repo.ID,
362-
Type: unit.TypeExternalUncyclo,
361+
Type: unit_model.TypeExternalUncyclo,
363362
Config: &models.ExternalUncycloConfig{
364363
ExternalUncycloURL: form.ExternalUncycloURL,
365364
},
366365
})
367-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeUncyclo)
368-
} else if form.EnableUncyclo && !form.EnableExternalUncyclo && !unit.TypeUncyclo.UnitGlobalDisabled() {
366+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeUncyclo)
367+
} else if form.EnableUncyclo && !form.EnableExternalUncyclo && !unit_model.TypeUncyclo.UnitGlobalDisabled() {
369368
units = append(units, models.RepoUnit{
370369
RepoID: repo.ID,
371-
Type: unit.TypeUncyclo,
370+
Type: unit_model.TypeUncyclo,
372371
Config: new(models.UnitConfig),
373372
})
374-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeExternalUncyclo)
373+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalUncyclo)
375374
} else {
376-
if !unit.TypeExternalUncyclo.UnitGlobalDisabled() {
377-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeExternalUncyclo)
375+
if !unit_model.TypeExternalUncyclo.UnitGlobalDisabled() {
376+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalUncyclo)
378377
}
379-
if !unit.TypeUncyclo.UnitGlobalDisabled() {
380-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeUncyclo)
378+
if !unit_model.TypeUncyclo.UnitGlobalDisabled() {
379+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeUncyclo)
381380
}
382381
}
383382

384-
if form.EnableIssues && form.EnableExternalTracker && !unit.TypeExternalTracker.UnitGlobalDisabled() {
383+
if form.EnableIssues && form.EnableExternalTracker && !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
385384
if !validation.IsValidExternalURL(form.ExternalTrackerURL) {
386385
ctx.Flash.Error(ctx.Tr("repo.settings.external_tracker_url_error"))
387386
ctx.Redirect(repo.Link() + "/settings")
@@ -394,47 +393,47 @@ func SettingsPost(ctx *context.Context) {
394393
}
395394
units = append(units, models.RepoUnit{
396395
RepoID: repo.ID,
397-
Type: unit.TypeExternalTracker,
396+
Type: unit_model.TypeExternalTracker,
398397
Config: &models.ExternalTrackerConfig{
399398
ExternalTrackerURL: form.ExternalTrackerURL,
400399
ExternalTrackerFormat: form.TrackerURLFormat,
401400
ExternalTrackerStyle: form.TrackerIssueStyle,
402401
},
403402
})
404-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeIssues)
405-
} else if form.EnableIssues && !form.EnableExternalTracker && !unit.TypeIssues.UnitGlobalDisabled() {
403+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeIssues)
404+
} else if form.EnableIssues && !form.EnableExternalTracker && !unit_model.TypeIssues.UnitGlobalDisabled() {
406405
units = append(units, models.RepoUnit{
407406
RepoID: repo.ID,
408-
Type: unit.TypeIssues,
407+
Type: unit_model.TypeIssues,
409408
Config: &models.IssuesConfig{
410409
EnableTimetracker: form.EnableTimetracker,
411410
AllowOnlyContributorsToTrackTime: form.AllowOnlyContributorsToTrackTime,
412411
EnableDependencies: form.EnableIssueDependencies,
413412
},
414413
})
415-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeExternalTracker)
414+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker)
416415
} else {
417-
if !unit.TypeExternalTracker.UnitGlobalDisabled() {
418-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeExternalTracker)
416+
if !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
417+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker)
419418
}
420-
if !unit.TypeIssues.UnitGlobalDisabled() {
421-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeIssues)
419+
if !unit_model.TypeIssues.UnitGlobalDisabled() {
420+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeIssues)
422421
}
423422
}
424423

425-
if form.EnableProjects && !unit.TypeProjects.UnitGlobalDisabled() {
424+
if form.EnableProjects && !unit_model.TypeProjects.UnitGlobalDisabled() {
426425
units = append(units, models.RepoUnit{
427426
RepoID: repo.ID,
428-
Type: unit.TypeProjects,
427+
Type: unit_model.TypeProjects,
429428
})
430-
} else if !unit.TypeProjects.UnitGlobalDisabled() {
431-
deleteUnitTypes = append(deleteUnitTypes, unit.TypeProjects)
429+
} else if !unit_model.TypeProjects.UnitGlobalDisabled() {
430+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeProjects)
432431
}
433432

434-
if form.EnablePulls && !unit.TypePullRequests.UnitGlobalDisabled() {
433+
if form.EnablePulls && !unit_model.TypePullRequests.UnitGlobalDisabled() {
435434
units = append(units, models.RepoUnit{
436435
RepoID: repo.ID,
437-
Type: unit.TypePullRequests,
436+
Type: unit_model.TypePullRequests,
438437
Config: &models.PullRequestsConfig{
439438
IgnoreWhitespaceConflicts: form.PullsIgnoreWhitespace,
440439
AllowMerge: form.PullsAllowMerge,
@@ -447,8 +446,8 @@ func SettingsPost(ctx *context.Context) {
447446
DefaultMergeStyle: models.MergeStyle(form.PullsDefaultMergeStyle),
448447
},
449448
})
450-
} else if !unit.TypePullRequests.UnitGlobalDisabled() {
451-
deleteUnitTypes = append(deleteUnitTypes, unit.TypePullRequests)
449+
} else if !unit_model.TypePullRequests.UnitGlobalDisabled() {
450+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePullRequests)
452451
}
453452

454453
if err := models.UpdateRepositoryUnits(repo, units, deleteUnitTypes); err != nil {

0 commit comments

Comments
 (0)