diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/auth/repo_form.go | 1 | ||||
-rw-r--r-- | modules/context/repo.go | 11 |
2 files changed, 11 insertions, 1 deletions
diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index a600ecc8fe..ff64d9a56b 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -117,6 +117,7 @@ type RepoSettingForm struct { EnableTimetracker bool AllowOnlyContributorsToTrackTime bool EnableIssueDependencies bool + IsArchived bool // Admin settings EnableHealthCheck bool diff --git a/modules/context/repo.go b/modules/context/repo.go index c10abdcb7b..310aa886d3 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -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) { |