mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	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>
This commit is contained in:
		
				
					committed by
					
						 Lauris BH
						Lauris BH
					
				
			
			
				
	
			
			
			
						parent
						
							36943e56d6
						
					
				
				
					commit
					3c07d03c03
				
			| @@ -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 | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user