mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 11:28:24 +00:00 
			
		
		
		
	Feature: Archive repos (#5009)
This commit is contained in:
		| @@ -56,7 +56,7 @@ type Repository struct { | ||||
|  | ||||
| // CanEnableEditor returns true if repository is editable and user has proper access level. | ||||
| func (r *Repository) CanEnableEditor() bool { | ||||
| 	return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanEnableEditor() && r.IsViewBranch | ||||
| 	return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanEnableEditor() && r.IsViewBranch && !r.Repository.IsArchived | ||||
| } | ||||
|  | ||||
| // CanCreateBranch returns true if repository is editable and user has proper access level. | ||||
| @@ -64,6 +64,15 @@ func (r *Repository) CanCreateBranch() bool { | ||||
| 	return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanCreateBranch() | ||||
| } | ||||
|  | ||||
| // RepoMustNotBeArchived checks if a repo is archived | ||||
| func RepoMustNotBeArchived() macaron.Handler { | ||||
| 	return func(ctx *Context) { | ||||
| 		if ctx.Repo.Repository.IsArchived { | ||||
| 			ctx.NotFound("IsArchived", fmt.Errorf(ctx.Tr("repo.archive.title"))) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // CanCommitToBranch returns true if repository is editable and user has proper access level | ||||
| //   and branch is not protected for push | ||||
| func (r *Repository) CanCommitToBranch(doer *models.User) (bool, error) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user