summaryrefslogtreecommitdiffstats
path: root/models/repo_unit.go
diff options
context:
space:
mode:
authorDavid Svantesson <davidsvantesson@gmail.com>2020-01-17 08:34:37 +0100
committerLauris BH <lauris@nix.lv>2020-01-17 09:34:37 +0200
commit3c07d03c0388d3b86138572401281b51f2db9282 (patch)
tree06eecf8b818ee8721a5dbfdd688eb5f45e5bef51 /models/repo_unit.go
parent36943e56d66a2d711a6b0c27219ce91a3ddc020a (diff)
downloadgitea-3c07d03c0388d3b86138572401281b51f2db9282.tar.gz
gitea-3c07d03c0388d3b86138572401281b51f2db9282.zip
Add setting to set default and global disabled repository units. (#8788)
* Add possibility to global disable repo units. * Add Default Repo Unit app.ini setting. * Hide units * Hide disabled repo units * Minor fixes * Indicate disabled units in team settings. Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/repo_unit.go')
-rw-r--r--models/repo_unit.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/models/repo_unit.go b/models/repo_unit.go
index a6162a65e5..ec680c395e 100644
--- a/models/repo_unit.go
+++ b/models/repo_unit.go
@@ -170,5 +170,16 @@ func (r *RepoUnit) ExternalTrackerConfig() *ExternalTrackerConfig {
}
func getUnitsByRepoID(e Engine, repoID int64) (units []*RepoUnit, err error) {
- return units, e.Where("repo_id = ?", repoID).Find(&units)
+ var tmpUnits []*RepoUnit
+ if err := e.Where("repo_id = ?", repoID).Find(&tmpUnits); err != nil {
+ return nil, err
+ }
+
+ for _, u := range tmpUnits {
+ if !u.Type.UnitGlobalDisabled() {
+ units = append(units, u)
+ }
+ }
+
+ return units, nil
}