summaryrefslogtreecommitdiffstats
path: root/models/repo/wiki.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-08-25 10:31:57 +0800
committerGitHub <noreply@github.com>2022-08-25 10:31:57 +0800
commit1d8543e7db58d7c4973758e47f005c4d8bd7d7a3 (patch)
treeb60c99e2dfd69ccb998f8a0829d98d7cadcf0d6b /models/repo/wiki.go
parent4a4bfafa238bf48851f8c11fa3701bd42b912475 (diff)
downloadgitea-1d8543e7db58d7c4973758e47f005c4d8bd7d7a3.tar.gz
gitea-1d8543e7db58d7c4973758e47f005c4d8bd7d7a3.zip
Move some files into models' sub packages (#20262)
* Move some files into models' sub packages * Move functions * merge main branch * Fix check * fix check * Fix some tests * Fix lint * Fix lint * Revert lint changes * Fix error comments * Fix lint Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models/repo/wiki.go')
-rw-r--r--models/repo/wiki.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/models/repo/wiki.go b/models/repo/wiki.go
index abf0155cad..72ec7c394b 100644
--- a/models/repo/wiki.go
+++ b/models/repo/wiki.go
@@ -6,6 +6,7 @@
package repo
import (
+ "fmt"
"path/filepath"
"strings"
@@ -14,6 +15,51 @@ import (
"code.gitea.io/gitea/modules/util"
)
+// ErrWikiAlreadyExist represents a "WikiAlreadyExist" kind of error.
+type ErrWikiAlreadyExist struct {
+ Title string
+}
+
+// IsErrWikiAlreadyExist checks if an error is an ErrWikiAlreadyExist.
+func IsErrWikiAlreadyExist(err error) bool {
+ _, ok := err.(ErrWikiAlreadyExist)
+ return ok
+}
+
+func (err ErrWikiAlreadyExist) Error() string {
+ return fmt.Sprintf("wiki page already exists [title: %s]", err.Title)
+}
+
+// ErrWikiReservedName represents a reserved name error.
+type ErrWikiReservedName struct {
+ Title string
+}
+
+// IsErrWikiReservedName checks if an error is an ErrWikiReservedName.
+func IsErrWikiReservedName(err error) bool {
+ _, ok := err.(ErrWikiReservedName)
+ return ok
+}
+
+func (err ErrWikiReservedName) Error() string {
+ return fmt.Sprintf("wiki title is reserved: %s", err.Title)
+}
+
+// ErrWikiInvalidFileName represents an invalid wiki file name.
+type ErrWikiInvalidFileName struct {
+ FileName string
+}
+
+// IsErrWikiInvalidFileName checks if an error is an ErrWikiInvalidFileName.
+func IsErrWikiInvalidFileName(err error) bool {
+ _, ok := err.(ErrWikiInvalidFileName)
+ return ok
+}
+
+func (err ErrWikiInvalidFileName) Error() string {
+ return fmt.Sprintf("Invalid wiki filename: %s", err.FileName)
+}
+
// WikiCloneLink returns clone URLs of repository wiki.
func (repo *Repository) WikiCloneLink() *CloneLink {
return repo.cloneLink(true)