aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-22 01:43:29 +0200
committerGitHub <noreply@github.com>2023-09-21 23:43:29 +0000
commit28f9b313bab420be8f42e546015312904311adba (patch)
treef3f09c6cef7bf96c7f390ba8e858cf80b0445581 /models/repo
parent7520cd678c3ef037db702296192d8664b6f02a54 (diff)
downloadgitea-28f9b313bab420be8f42e546015312904311adba.tar.gz
gitea-28f9b313bab420be8f42e546015312904311adba.zip
Updates to the API for archived repos (#27149)
Diffstat (limited to 'models/repo')
-rw-r--r--models/repo/repo.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/models/repo/repo.go b/models/repo/repo.go
index 5ebc7bfc24..0b0c029993 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -47,6 +47,14 @@ func (err ErrUserDoesNotHaveAccessToRepo) Unwrap() error {
return util.ErrPermissionDenied
}
+type ErrRepoIsArchived struct {
+ Repo *Repository
+}
+
+func (err ErrRepoIsArchived) Error() string {
+ return fmt.Sprintf("%s is archived", err.Repo.LogString())
+}
+
var (
reservedRepoNames = []string{".", "..", "-"}
reservedRepoPatterns = []string{"*.git", "*.wiki", "*.rss", "*.atom"}
@@ -654,6 +662,14 @@ func (repo *Repository) GetTrustModel() TrustModelType {
return trustModel
}
+// MustNotBeArchived returns ErrRepoIsArchived if the repo is archived
+func (repo *Repository) MustNotBeArchived() error {
+ if repo.IsArchived {
+ return ErrRepoIsArchived{Repo: repo}
+ }
+ return nil
+}
+
// __________ .__ __
// \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |