summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index 7ad9ad4dc9..a6817f6514 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -383,7 +383,9 @@ func (repo *Repository) getUnitsByUserID(e Engine, userID int64, isAdmin bool) (
// UnitEnabled if this repository has the given unit enabled
func (repo *Repository) UnitEnabled(tp UnitType) bool {
- repo.getUnits(x)
+ if err := repo.getUnits(x); err != nil {
+ log.Warn("Error loading repository (ID: %d) units: %s", repo.ID, err.Error())
+ }
for _, unit := range repo.Units {
if unit.Type == tp {
return true
@@ -392,6 +394,21 @@ func (repo *Repository) UnitEnabled(tp UnitType) bool {
return false
}
+// AnyUnitEnabled if this repository has the any of the given units enabled
+func (repo *Repository) AnyUnitEnabled(tps ...UnitType) bool {
+ if err := repo.getUnits(x); err != nil {
+ log.Warn("Error loading repository (ID: %d) units: %s", repo.ID, err.Error())
+ }
+ for _, unit := range repo.Units {
+ for _, tp := range tps {
+ if unit.Type == tp {
+ return true
+ }
+ }
+ }
+ return false
+}
+
var (
// ErrUnitNotExist organization does not exist
ErrUnitNotExist = errors.New("Unit does not exist")