diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-08-25 10:31:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 10:31:57 +0800 |
commit | 1d8543e7db58d7c4973758e47f005c4d8bd7d7a3 (patch) | |
tree | b60c99e2dfd69ccb998f8a0829d98d7cadcf0d6b /services/wiki | |
parent | 4a4bfafa238bf48851f8c11fa3701bd42b912475 (diff) | |
download | gitea-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 'services/wiki')
-rw-r--r-- | services/wiki/wiki.go | 7 | ||||
-rw-r--r-- | services/wiki/wiki_test.go | 9 |
2 files changed, 7 insertions, 9 deletions
diff --git a/services/wiki/wiki.go b/services/wiki/wiki.go index 43e35eed69..ac5283bbeb 100644 --- a/services/wiki/wiki.go +++ b/services/wiki/wiki.go @@ -12,7 +12,6 @@ import ( "os" "strings" - "code.gitea.io/gitea/models" admin_model "code.gitea.io/gitea/models/admin" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unit" @@ -33,7 +32,7 @@ var ( func nameAllowed(name string) error { if util.IsStringInSlice(name, reservedWikiNames) { - return models.ErrWikiReservedName{ + return repo_model.ErrWikiReservedName{ Title: name, } } @@ -59,7 +58,7 @@ func NameToFilename(name string) string { // FilenameToName converts a wiki filename to its corresponding page name. func FilenameToName(filename string) (string, error) { if !strings.HasSuffix(filename, ".md") { - return "", models.ErrWikiInvalidFileName{ + return "", repo_model.ErrWikiInvalidFileName{ FileName: filename, } } @@ -178,7 +177,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model if isNew { if isWikiExist { - return models.ErrWikiAlreadyExist{ + return repo_model.ErrWikiAlreadyExist{ Title: newWikiPath, } } diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go index 1852ddbcb3..938a7d6acd 100644 --- a/services/wiki/wiki_test.go +++ b/services/wiki/wiki_test.go @@ -9,7 +9,6 @@ import ( "path/filepath" "testing" - "code.gitea.io/gitea/models" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" @@ -90,11 +89,11 @@ func TestWikiFilenameToName(t *testing.T) { } { _, err := FilenameToName(badFilename) assert.Error(t, err) - assert.True(t, models.IsErrWikiInvalidFileName(err)) + assert.True(t, repo_model.IsErrWikiInvalidFileName(err)) } _, err := FilenameToName("badescaping%%.md") assert.Error(t, err) - assert.False(t, models.IsErrWikiInvalidFileName(err)) + assert.False(t, repo_model.IsErrWikiInvalidFileName(err)) } func TestWikiNameToFilenameToName(t *testing.T) { @@ -157,7 +156,7 @@ func TestRepository_AddWikiPage(t *testing.T) { // test for already-existing wiki name err := AddWikiPage(git.DefaultContext, doer, repo, "Home", wikiContent, commitMsg) assert.Error(t, err) - assert.True(t, models.IsErrWikiAlreadyExist(err)) + assert.True(t, repo_model.IsErrWikiAlreadyExist(err)) }) t.Run("check wiki reserved name", func(t *testing.T) { @@ -165,7 +164,7 @@ func TestRepository_AddWikiPage(t *testing.T) { // test for reserved wiki name err := AddWikiPage(git.DefaultContext, doer, repo, "_edit", wikiContent, commitMsg) assert.Error(t, err) - assert.True(t, models.IsErrWikiReservedName(err)) + assert.True(t, repo_model.IsErrWikiReservedName(err)) }) } |