mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 19:38:23 +00:00 
			
		
		
		
	Move repository visibility to danger zone in the settings area (#31126)
Moved repository visibility to the danger zone in the settings area. To change the visibility, it is necessary to go to the danger zone, click on the private/public button, and accept the change in the modal. Resolves: #23826 --- ## Screenshots <details> <summary>Before</summary> Private repo:  Public repo:  </details> <details> <summary>After</summary> Make private:  Make private modal   Make public:  Make public modal  </details> --------- Co-authored-by: Kemal Zebari <60799661+kemzeb@users.noreply.github.com>
This commit is contained in:
		| @@ -122,6 +122,31 @@ func UpdateRepository(ctx context.Context, repo *repo_model.Repository, visibili | ||||
| 	return committer.Commit() | ||||
| } | ||||
|  | ||||
| func UpdateRepositoryVisibility(ctx context.Context, repo *repo_model.Repository, isPrivate bool) (err error) { | ||||
| 	ctx, committer, err := db.TxContext(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	defer committer.Close() | ||||
|  | ||||
| 	repo.IsPrivate = isPrivate | ||||
|  | ||||
| 	if err = repo_module.UpdateRepository(ctx, repo, true); err != nil { | ||||
| 		return fmt.Errorf("UpdateRepositoryVisibility: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	return committer.Commit() | ||||
| } | ||||
|  | ||||
| func MakeRepoPublic(ctx context.Context, repo *repo_model.Repository) (err error) { | ||||
| 	return UpdateRepositoryVisibility(ctx, repo, false) | ||||
| } | ||||
|  | ||||
| func MakeRepoPrivate(ctx context.Context, repo *repo_model.Repository) (err error) { | ||||
| 	return UpdateRepositoryVisibility(ctx, repo, true) | ||||
| } | ||||
|  | ||||
| // LinkedRepository returns the linked repo if any | ||||
| func LinkedRepository(ctx context.Context, a *repo_model.Attachment) (*repo_model.Repository, unit.Type, error) { | ||||
| 	if a.IssueID != 0 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user