Skip to content

Commit d483407

Browse files
authored
Repository level enable package or disable (#19323)
1 parent 6a96968 commit d483407

File tree

14 files changed

+65
-4
lines changed

14 files changed

+65
-4
lines changed

integrations/mssql.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
102102

103103
[lfs]
104104
PATH = integrations/gitea-integration-mssql/data/lfs
105+
106+
[packages]
107+
ENABLED = true

integrations/mysql.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,6 @@ DISABLE_GIT_HOOKS = false
118118
INSTALL_LOCK = true
119119
SECRET_KEY = 9pCviYTWSb
120120
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.hhSVGOANkaKk3vfCd2jDOIww4pUk0xtg9JRde5UogyQ
121+
122+
[packages]
123+
ENABLED = true

integrations/mysql8.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
9999

100100
[lfs]
101101
PATH = integrations/gitea-integration-mysql8/data/lfs
102+
103+
[packages]
104+
ENABLED = true

integrations/pgsql.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
103103

104104
[lfs]
105105
PATH = integrations/gitea-integration-pgsql/data/lfs
106+
107+
[packages]
108+
ENABLED = true

integrations/sqlite.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ JWT_SECRET = KZb_QLUd4fYVyxetjxC4eZkrBgWM2SndOOWDNtgUUko
101101

102102
[lfs]
103103
PATH = integrations/gitea-integration-sqlite/data/lfs
104+
105+
[packages]
106+
ENABLED = true

models/repo/repo_unit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) {
181181
r.Config = new(PullRequestsConfig)
182182
case unit.TypeIssues:
183183
r.Config = new(IssuesConfig)
184-
case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects:
184+
case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects, unit.TypePackages:
185185
fallthrough
186186
default:
187187
r.Config = new(UnitConfig)

models/unit/unit.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const (
2727
TypeExternalWiki // 6 ExternalWiki
2828
TypeExternalTracker // 7 ExternalTracker
2929
TypeProjects // 8 Kanban board
30+
TypePackages // 9 Packages
3031
)
3132

3233
// Value returns integer value for unit type
@@ -52,6 +53,8 @@ func (u Type) String() string {
5253
return "TypeExternalTracker"
5354
case TypeProjects:
5455
return "TypeProjects"
56+
case TypePackages:
57+
return "TypePackages"
5558
}
5659
return fmt.Sprintf("Unknown Type %d", u)
5760
}
@@ -74,6 +77,7 @@ var (
7477
TypeExternalWiki,
7578
TypeExternalTracker,
7679
TypeProjects,
80+
TypePackages,
7781
}
7882

7983
// DefaultRepoUnits contains the default unit types
@@ -84,6 +88,7 @@ var (
8488
TypeReleases,
8589
TypeWiki,
8690
TypeProjects,
91+
TypePackages,
8792
}
8893

8994
// NotAllowedDefaultRepoUnits contains units that can't be default
@@ -275,6 +280,15 @@ var (
275280
perm.AccessModeOwner,
276281
}
277282

283+
UnitPackages = Unit{
284+
TypePackages,
285+
"repo.packages",
286+
"/packages",
287+
"repo.packages.desc",
288+
6,
289+
perm.AccessModeRead,
290+
}
291+
278292
// Units contains all the units
279293
Units = map[Type]Unit{
280294
TypeCode: UnitCode,
@@ -285,6 +299,7 @@ var (
285299
TypeWiki: UnitWiki,
286300
TypeExternalWiki: UnitExternalWiki,
287301
TypeProjects: UnitProjects,
302+
TypePackages: UnitPackages,
288303
}
289304
)
290305

modules/context/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,7 @@ func UnitTypes() func(ctx *Context) {
10191019
ctx.Data["UnitTypeExternalWiki"] = unit_model.TypeExternalWiki
10201020
ctx.Data["UnitTypeExternalTracker"] = unit_model.TypeExternalTracker
10211021
ctx.Data["UnitTypeProjects"] = unit_model.TypeProjects
1022+
ctx.Data["UnitTypePackages"] = unit_model.TypePackages
10221023
}
10231024
}
10241025

modules/setting/repository.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ func newRepository() {
295295
log.Fatal("Failed to map Repository.PullRequest settings: %v", err)
296296
}
297297

298+
if !Cfg.Section("packages").Key("ENABLED").MustBool(false) {
299+
Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.packages")
300+
}
301+
298302
// Handle default trustmodel settings
299303
Repository.Signing.DefaultTrustModel = strings.ToLower(strings.TrimSpace(Repository.Signing.DefaultTrustModel))
300304
if Repository.Signing.DefaultTrustModel == "default" {

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ tags = Tags
10111011
issues = Issues
10121012
pulls = Pull Requests
10131013
project_board = Projects
1014+
packages = Packages
10141015
labels = Labels
10151016
org_labels_desc = Organization level labels that can be used with <strong>all repositories</strong> under this organization
10161017
org_labels_desc_manage = manage

0 commit comments

Comments
 (0)