summaryrefslogtreecommitdiffstats
path: root/models/repo.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.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.go')
-rw-r--r--models/repo.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/models/repo.go b/models/repo.go
index 2c9dafefc9..6c89dbcbbb 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -128,6 +128,7 @@ func loadRepoConfig() {
// NewRepoContext creates a new repository context
func NewRepoContext() {
loadRepoConfig()
+ loadUnitConfig()
RemoveAllWithNotice("Clean up repository temporary data", filepath.Join(setting.AppDataPath, "tmp"))
}
@@ -393,6 +394,7 @@ func (repo *Repository) getUnits(e Engine) (err error) {
}
repo.Units, err = getUnitsByRepoID(e, repo.ID)
+ log.Trace("repo.Units: %-+v", repo.Units)
return err
}
@@ -1442,14 +1444,19 @@ func UpdateRepositoryUpdatedTime(repoID int64, updateTime time.Time) error {
}
// UpdateRepositoryUnits updates a repository's units
-func UpdateRepositoryUnits(repo *Repository, units []RepoUnit) (err error) {
+func UpdateRepositoryUnits(repo *Repository, units []RepoUnit, deleteUnitTypes []UnitType) (err error) {
sess := x.NewSession()
defer sess.Close()
if err = sess.Begin(); err != nil {
return err
}
- if _, err = sess.Where("repo_id = ?", repo.ID).Delete(new(RepoUnit)); err != nil {
+ // Delete existing settings of units before adding again
+ for _, u := range units {
+ deleteUnitTypes = append(deleteUnitTypes, u.Type)
+ }
+
+ if _, err = sess.Where("repo_id = ?", repo.ID).In("type", deleteUnitTypes).Delete(new(RepoUnit)); err != nil {
return err
}