Skip to content

Add invlid value check to DISABLED_REPO_UNITS and fix incorrect slice combine #23024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions models/unit/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,14 @@ func validateDefaultRepoUnits(defaultUnits, settingDefaultUnits []Type) []Type {

// LoadUnitConfig load units from settings
func LoadUnitConfig() {
DisabledRepoUnits = FindUnitTypes(setting.Repository.DisabledRepoUnits...)
disabledRepoUnits := FindUnitTypes(setting.Repository.DisabledRepoUnits...)
// Check that must units are not disabled
for i, disabledU := range DisabledRepoUnits {
if !disabledU.CanDisable() {
DisabledRepoUnits = disabledRepoUnits[:0]
for _, disabledU := range disabledRepoUnits {
if !disabledU.CanDisable() || disabledU.IsInvalid() {
log.Warn("Not allowed to global disable unit %s", disabledU.String())
DisabledRepoUnits = append(DisabledRepoUnits[:i], DisabledRepoUnits[i+1:]...)
} else {
DisabledRepoUnits = append(DisabledRepoUnits, disabledU)
}
}

Expand All @@ -176,6 +178,11 @@ func (u Type) UnitGlobalDisabled() bool {
return false
}

// IsInvalid checks if this unit type is invalid.
func (u *Type) IsInvalid() bool {
return *u == TypeInvalid
}

// CanDisable checks if this unit type can be disabled.
func (u *Type) CanDisable() bool {
for _, mu := range MustRepoUnits {
Expand Down