fix: resolve build errors in v2 API and wiki service
Some checks failed
Build and Release / Lint and Test (push) Successful in 2m57s
Build and Release / Build Binaries (amd64, darwin) (push) Failing after 54s
Build and Release / Build Binaries (amd64, linux) (push) Failing after 1m26s
Build and Release / Build Binaries (amd64, windows) (push) Failing after 1m16s
Build and Release / Build Binaries (arm64, darwin) (push) Failing after 1m20s
Build and Release / Build Docker Image (push) Failing after 16s
Build and Release / Build Binaries (arm64, linux) (push) Failing after 1m14s
Build and Release / Create Release (push) Has been skipped
Some checks failed
Build and Release / Lint and Test (push) Successful in 2m57s
Build and Release / Build Binaries (amd64, darwin) (push) Failing after 54s
Build and Release / Build Binaries (amd64, linux) (push) Failing after 1m26s
Build and Release / Build Binaries (amd64, windows) (push) Failing after 1m16s
Build and Release / Build Binaries (arm64, darwin) (push) Failing after 1m20s
Build and Release / Build Docker Image (push) Failing after 16s
Build and Release / Build Binaries (arm64, linux) (push) Failing after 1m14s
Build and Release / Create Release (push) Has been skipped
- Fix wiki_index.go: use WebPathToGitPath/GitPathToWebPath instead of undefined functions - Fix wiki_index.go: use gitrepo.OpenRepository pattern instead of repo.WikiPath() - Fix wiki.go: use markdown.Render instead of undefined RenderWiki - Fix wiki.go: use charset.ToUTF8WithFallbackReader instead of undefined ToUTF8Reader - Fix wiki.go: use gitrepo.CommitsCount instead of undefined wikiRepo.CommitsCount - Fix wiki.go: handle WebPathToUserTitle returning two values - Fix gofmt formatting issues in v2 API files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b8b276fa05
commit
ee5cf4e4fd
@ -114,9 +114,10 @@ func ListWikiPagesV2(ctx *context.APIContext) {
|
||||
// Get last commit for this page
|
||||
lastCommit, _ := wikiRepo.GetCommitByPath(entry.Name())
|
||||
|
||||
_, pageTitle := wiki_service.WebPathToUserTitle(wikiName)
|
||||
page := &api.WikiPageV2{
|
||||
Name: string(wikiName),
|
||||
Title: wiki_service.WebPathToUserTitle(wikiName),
|
||||
Title: pageTitle,
|
||||
Path: entry.Name(),
|
||||
URL: setting.AppURL + repo.FullName() + "/wiki/" + string(wikiName),
|
||||
HTMLURL: setting.AppURL + repo.FullName() + "/wiki/" + string(wikiName),
|
||||
@ -205,13 +206,12 @@ func GetWikiPageV2(ctx *context.APIContext) {
|
||||
|
||||
// Render HTML
|
||||
var htmlContent string
|
||||
if rd, err := charset.ToUTF8Reader(nil, strings.NewReader(content)); err == nil {
|
||||
rd := charset.ToUTF8WithFallbackReader(strings.NewReader(content), charset.ConvertOpts{})
|
||||
if buf := new(strings.Builder); buf != nil {
|
||||
if err := markdown.RenderWiki(ctx, markup.NewRenderContext(ctx).WithRelativePath(gitFilename), rd, buf); err == nil {
|
||||
if err := markdown.Render(markup.NewRenderContext(ctx).WithRelativePath(gitFilename), rd, buf); err == nil {
|
||||
htmlContent = buf.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get last commit
|
||||
lastCommit, _ := wikiRepo.GetCommitByPath(gitFilename)
|
||||
@ -236,9 +236,10 @@ func GetWikiPageV2(ctx *context.APIContext) {
|
||||
linksIn = incoming
|
||||
}
|
||||
|
||||
_, pageTitle := wiki_service.WebPathToUserTitle(wikiName)
|
||||
page := &api.WikiPageV2{
|
||||
Name: string(wikiName),
|
||||
Title: wiki_service.WebPathToUserTitle(wikiName),
|
||||
Title: pageTitle,
|
||||
Path: gitFilename,
|
||||
URL: setting.AppURL + "api/v2/repos/" + repo.FullName() + "/wiki/pages/" + string(wikiName),
|
||||
HTMLURL: setting.AppURL + repo.FullName() + "/wiki/" + string(wikiName),
|
||||
@ -707,8 +708,8 @@ func GetWikiStatsV2(ctx *context.APIContext) {
|
||||
if err == nil && wikiRepo != nil {
|
||||
defer wikiRepo.Close()
|
||||
// Get commit count
|
||||
if count, err := wikiRepo.CommitsCount(&git.CommitsCountOptions{
|
||||
Branch: repo.DefaultWikiBranch,
|
||||
if count, err := gitrepo.CommitsCount(ctx, repo.WikiStorageRepo(), gitrepo.CommitsCountOptions{
|
||||
Revision: []string{repo.DefaultWikiBranch},
|
||||
}); err == nil {
|
||||
totalCommits = count
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/gitrepo"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
@ -30,7 +31,7 @@ func IndexWikiPage(ctx context.Context, repo *repo_model.Repository, pageName st
|
||||
}
|
||||
|
||||
// Get the page content
|
||||
pagePath := NameToFilename(pageName)
|
||||
pagePath := WebPathToGitPath(WebPath(pageName))
|
||||
entry, err := commit.GetTreeEntryByPath(pagePath)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -110,7 +111,11 @@ func IndexAllWikiPages(ctx context.Context, repo *repo_model.Repository) error {
|
||||
continue
|
||||
}
|
||||
|
||||
pageName := FilenameToName(entry.Name())
|
||||
webPath, err := GitPathToWebPath(entry.Name())
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
pageName := string(webPath)
|
||||
if pageName == "" {
|
||||
continue
|
||||
}
|
||||
@ -278,14 +283,11 @@ func GetDeadLinks(ctx context.Context, repoID int64) ([]map[string]string, error
|
||||
|
||||
// findWikiRepoCommit opens the wiki repo and gets the latest commit
|
||||
func findWikiRepoCommit(ctx context.Context, repo *repo_model.Repository) (*git.Repository, *git.Commit, error) {
|
||||
wikiPath := repo.WikiPath()
|
||||
|
||||
if !git.IsRepoURLAccessible(ctx, wikiPath) {
|
||||
wikiRepo, err := gitrepo.OpenRepository(ctx, repo.WikiStorageRepo())
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
wikiRepo, err := git.OpenRepository(ctx, wikiPath)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@ -297,6 +299,9 @@ func findWikiRepoCommit(ctx context.Context, repo *repo_model.Repository) (*git.
|
||||
commit, err := wikiRepo.GetBranchCommit(branch)
|
||||
if err != nil {
|
||||
wikiRepo.Close()
|
||||
if git.IsErrNotExist(err) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user