Move HasWiki to repository service package (#33912)

Move HasWiki out of the models package to avoid referencing the absolute
wiki path directly.
This commit is contained in:
Lunny Xiao
2025-09-01 11:12:58 -07:00
committed by GitHub
parent ea96ff6b0c
commit 4e1b8db1fc
17 changed files with 76 additions and 54 deletions

View File

@@ -23,6 +23,7 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
repo_service "code.gitea.io/gitea/services/repository"
)
var stripExitStatus = regexp.MustCompile(`exit status \d+ - `)
@@ -47,7 +48,7 @@ func AddPushMirrorRemote(ctx context.Context, m *repo_model.PushMirror, addr str
return err
}
if m.Repo.HasWiki() {
if repo_service.HasWiki(ctx, m.Repo) {
wikiRemoteURL := repository.WikiRemoteURL(ctx, addr)
if len(wikiRemoteURL) > 0 {
if err := addRemoteAndConfig(wikiRemoteURL, m.Repo.WikiPath()); err != nil {
@@ -68,7 +69,7 @@ func RemovePushMirrorRemote(ctx context.Context, m *repo_model.PushMirror) error
return err
}
if m.Repo.HasWiki() {
if repo_service.HasWiki(ctx, m.Repo) {
if _, _, err := cmd.RunStdString(ctx, &git.RunOpts{Dir: m.Repo.WikiPath()}); err != nil {
// The wiki remote may not exist
log.Warn("Wiki Remote[%d] could not be removed: %v", m.ID, err)
@@ -183,7 +184,7 @@ func runPushSync(ctx context.Context, m *repo_model.PushMirror) error {
return err
}
if m.Repo.HasWiki() {
if repo_service.HasWiki(ctx, m.Repo) {
_, err := git.GetRemoteAddress(ctx, m.Repo.WikiPath(), m.RemoteName)
if err == nil {
err := performPush(m.Repo, true)