mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Feature: Archive repos (#5009)
This commit is contained in:
		@@ -117,6 +117,7 @@ type RepoSettingForm struct {
 | 
			
		||||
	EnableTimetracker                bool
 | 
			
		||||
	AllowOnlyContributorsToTrackTime bool
 | 
			
		||||
	EnableIssueDependencies          bool
 | 
			
		||||
	IsArchived                       bool
 | 
			
		||||
 | 
			
		||||
	// Admin settings
 | 
			
		||||
	EnableHealthCheck bool
 | 
			
		||||
 
 | 
			
		||||
@@ -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