diff options
author | kolaente <konrad@kola-entertainments.de> | 2019-01-23 19:58:38 +0100 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-01-23 13:58:38 -0500 |
commit | 0b510725c97452bac57ff0080df10f6177aa2a6e (patch) | |
tree | b9405cf290057698b32cf0acacc0d627f223ed6d /modules/context | |
parent | 6ad834e236756e7ba3de27e59681080a7ec4fcf1 (diff) | |
download | gitea-0b510725c97452bac57ff0080df10f6177aa2a6e.tar.gz gitea-0b510725c97452bac57ff0080df10f6177aa2a6e.zip |
Feature: Archive repos (#5009)
Diffstat (limited to 'modules/context')
-rw-r--r-- | modules/context/repo.go | 11 |
1 files changed, 10 insertions, 1 deletions
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) { |