mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Add absent repounits to create/edit repo API (#23500)
Adds the ability to enable/disable Actions, Packages and Releases from the API, via the Edit and Get Repository API endpoints.
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							8d9f8e10b1
						
					
				
				
					commit
					574d8fe6d6
				
			@@ -936,6 +936,39 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if opts.HasReleases != nil && !unit_model.TypeReleases.UnitGlobalDisabled() {
 | 
			
		||||
		if *opts.HasReleases {
 | 
			
		||||
			units = append(units, repo_model.RepoUnit{
 | 
			
		||||
				RepoID: repo.ID,
 | 
			
		||||
				Type:   unit_model.TypeReleases,
 | 
			
		||||
			})
 | 
			
		||||
		} else {
 | 
			
		||||
			deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeReleases)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if opts.HasPackages != nil && !unit_model.TypePackages.UnitGlobalDisabled() {
 | 
			
		||||
		if *opts.HasPackages {
 | 
			
		||||
			units = append(units, repo_model.RepoUnit{
 | 
			
		||||
				RepoID: repo.ID,
 | 
			
		||||
				Type:   unit_model.TypePackages,
 | 
			
		||||
			})
 | 
			
		||||
		} else {
 | 
			
		||||
			deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePackages)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if opts.HasActions != nil && !unit_model.TypeActions.UnitGlobalDisabled() {
 | 
			
		||||
		if *opts.HasActions {
 | 
			
		||||
			units = append(units, repo_model.RepoUnit{
 | 
			
		||||
				RepoID: repo.ID,
 | 
			
		||||
				Type:   unit_model.TypeActions,
 | 
			
		||||
			})
 | 
			
		||||
		} else {
 | 
			
		||||
			deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeActions)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := repo_model.UpdateRepositoryUnits(repo, units, deleteUnitTypes); err != nil {
 | 
			
		||||
		ctx.Error(http.StatusInternalServerError, "UpdateRepositoryUnits", err)
 | 
			
		||||
		return err
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user