0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-12-16 13:52:14 +01:00

Add DefaultWikiFormat var and its checks

This commit is contained in:
Aly Sewelam 2025-11-26 16:33:31 +02:00
parent 997ce9ffd1
commit f0c005be7d
4 changed files with 7 additions and 2 deletions

View File

@ -164,6 +164,7 @@ type Repository struct {
OriginalURL string `xorm:"VARCHAR(2048)"` OriginalURL string `xorm:"VARCHAR(2048)"`
DefaultBranch string DefaultBranch string
DefaultWikiBranch string DefaultWikiBranch string
DefaultWikiFormat string
NumWatches int NumWatches int
NumStars int NumStars int

View File

@ -524,6 +524,9 @@ func handleSettingsPostAdvanced(ctx *context.Context) {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeCode) deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeCode)
} }
if form.EnableWiki && form.DefaultWikiFormat {
}
if form.EnableWiki && form.EnableExternalWiki && !unit_model.TypeExternalWiki.UnitGlobalDisabled() { if form.EnableWiki && form.EnableExternalWiki && !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
if !validation.IsValidExternalURL(form.ExternalWikiURL) { if !validation.IsValidExternalURL(form.ExternalWikiURL) {
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error")) ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))

View File

@ -110,6 +110,7 @@ type RepoSettingForm struct {
// Advanced settings // Advanced settings
EnableCode bool EnableCode bool
DefaultWikiFormat string
EnableWiki bool EnableWiki bool
EnableExternalWiki bool EnableExternalWiki bool
DefaultWikiBranch string DefaultWikiBranch string

View File

@ -279,7 +279,7 @@ func TestPrepareWikiFileName(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
webPath := UserTitleToWebPath("", tt.arg) webPath := UserTitleToWebPath("", tt.arg)
existence, newWikiPath, err := prepareGitPath(gitRepo, repo.DefaultWikiBranch, webPath) existence, newWikiPath, err := prepareGitPath(gitRepo, repo.DefaultWikiBranch, webPath, "both")
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
assert.NoError(t, err) assert.NoError(t, err)
return return
@ -310,7 +310,7 @@ func TestPrepareWikiFileName_FirstPage(t *testing.T) {
defer gitRepo.Close() defer gitRepo.Close()
existence, newWikiPath, err := prepareGitPath(gitRepo, "master", "Home") existence, newWikiPath, err := prepareGitPath(gitRepo, "master", "Home", "both")
assert.False(t, existence) assert.False(t, existence)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "Home.md", newWikiPath) assert.Equal(t, "Home.md", newWikiPath)