@@ -14,6 +14,7 @@ import (
1414	"code.gitea.io/gitea/modules/container" 
1515	"code.gitea.io/gitea/modules/log" 
1616	"code.gitea.io/gitea/modules/setting" 
17+ 	"code.gitea.io/gitea/modules/util" 
1718)
1819
1920// Type is Unit's Type 
@@ -34,6 +35,10 @@ const (
3435	TypePackages         // 9 Packages 
3536	TypeActions          // 10 Actions 
3637
38+ 	// misc is a special uint to store special configs for a repo which is not related to any unit, 
39+ 	// it should be considered as enabled anyway 
40+ 	TypeMisc  Type  =  999  // 999 misc 
41+ 
3742	// FIXME: TEAM-UNIT-PERMISSION: the team unit "admin" permission's design is not right, when a new unit is added in the future, 
3843	// admin team won't inherit the correct admin permission for the new unit, need to have a complete fix before adding any new unit. 
3944)
6570		TypeProjects ,
6671		TypePackages ,
6772		TypeActions ,
73+ 		TypeMisc ,
6874	}
6975
7076	// DefaultRepoUnits contains the default unit types 
@@ -77,12 +83,14 @@ var (
7783		TypeProjects ,
7884		TypePackages ,
7985		TypeActions ,
86+ 		TypeMisc ,
8087	}
8188
8289	// ForkRepoUnits contains the default unit types for forks 
8390	DefaultForkRepoUnits  =  []Type {
8491		TypeCode ,
8592		TypePullRequests ,
93+ 		TypeMisc ,
8694	}
8795
8896	// DefaultMirrorRepoUnits contains the default unit types for mirrors 
93101		TypeWiki ,
94102		TypeProjects ,
95103		TypePackages ,
104+ 		TypeMisc ,
96105	}
97106
98107	// DefaultTemplateRepoUnits contains the default unit types for templates 
@@ -104,12 +113,14 @@ var (
104113		TypeWiki ,
105114		TypeProjects ,
106115		TypePackages ,
116+ 		TypeMisc ,
107117	}
108118
109119	// NotAllowedDefaultRepoUnits contains units that can't be default 
110120	NotAllowedDefaultRepoUnits  =  []Type {
111121		TypeExternalWiki ,
112122		TypeExternalTracker ,
123+ 		TypeMisc ,
113124	}
114125
115126	disabledRepoUnitsAtomic  atomic.Pointer [[]Type ] // the units that have been globally disabled 
@@ -163,6 +174,11 @@ func LoadUnitConfig() error {
163174	if  len (invalidKeys ) >  0  {
164175		log .Warn ("Invalid keys in disabled repo units: %s" , strings .Join (invalidKeys , ", " ))
165176	}
177+ 	if  slices .Contains (disabledRepoUnits , TypeMisc ) {
178+ 		log .Warn ("Misc unit should not be disabled" )
179+ 		disabledRepoUnits  =  util .SliceRemoveAll (disabledRepoUnits , TypeMisc )
180+ 	}
181+ 
166182	DisabledRepoUnitsSet (disabledRepoUnits )
167183
168184	setDefaultRepoUnits , invalidKeys  :=  FindUnitTypes (setting .Repository .DefaultRepoUnits ... )
@@ -328,6 +344,15 @@ var (
328344		perm .AccessModeOwner ,
329345	}
330346
347+ 	UnitMisc  =  Unit {
348+ 		TypeMisc ,
349+ 		"repo.misc" ,
350+ 		"/misc" ,
351+ 		"misc.unit.desc" ,
352+ 		999 ,
353+ 		perm .AccessModeOwner ,
354+ 	}
355+ 
331356	// Units contains all the units 
332357	Units  =  map [Type ]Unit {
333358		TypeCode :            UnitCode ,
@@ -340,6 +365,7 @@ var (
340365		TypeProjects :        UnitProjects ,
341366		TypePackages :        UnitPackages ,
342367		TypeActions :         UnitActions ,
368+ 		TypeMisc :            UnitMisc ,
343369	}
344370)
345371
0 commit comments