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
@ -64,17 +64,17 @@ type AIRepoSummaryResponse struct {
|
||||
|
||||
// Structure overview
|
||||
Structure struct {
|
||||
TopLevelDirs []string `json:"top_level_dirs"`
|
||||
TopLevelFiles []string `json:"top_level_files"`
|
||||
FileCount int `json:"total_file_count"`
|
||||
Languages map[string]int64 `json:"languages"` // language -> bytes
|
||||
HasReadme bool `json:"has_readme"`
|
||||
ReadmePath string `json:"readme_path,omitempty"`
|
||||
HasLicense bool `json:"has_license"`
|
||||
LicensePath string `json:"license_path,omitempty"`
|
||||
HasContrib bool `json:"has_contributing"`
|
||||
ContribPath string `json:"contributing_path,omitempty"`
|
||||
ConfigFiles []string `json:"config_files"` // package.json, go.mod, etc.
|
||||
TopLevelDirs []string `json:"top_level_dirs"`
|
||||
TopLevelFiles []string `json:"top_level_files"`
|
||||
FileCount int `json:"total_file_count"`
|
||||
Languages map[string]int64 `json:"languages"` // language -> bytes
|
||||
HasReadme bool `json:"has_readme"`
|
||||
ReadmePath string `json:"readme_path,omitempty"`
|
||||
HasLicense bool `json:"has_license"`
|
||||
LicensePath string `json:"license_path,omitempty"`
|
||||
HasContrib bool `json:"has_contributing"`
|
||||
ContribPath string `json:"contributing_path,omitempty"`
|
||||
ConfigFiles []string `json:"config_files"` // package.json, go.mod, etc.
|
||||
} `json:"structure"`
|
||||
|
||||
// Recent activity
|
||||
@ -377,8 +377,8 @@ type AIIssueContextResponse struct {
|
||||
|
||||
// AI hints
|
||||
AIHints struct {
|
||||
Category string `json:"category"` // "bug", "feature", "question", etc.
|
||||
Complexity string `json:"complexity"` // "simple", "moderate", "complex"
|
||||
Category string `json:"category"` // "bug", "feature", "question", etc.
|
||||
Complexity string `json:"complexity"` // "simple", "moderate", "complex"
|
||||
SuggestedFiles []string `json:"suggested_files,omitempty"`
|
||||
} `json:"ai_hints"`
|
||||
}
|
||||
|
||||
@ -12,12 +12,12 @@ import (
|
||||
|
||||
// HealthCheckResponse represents the health check response
|
||||
type HealthCheckResponse struct {
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Uptime float64 `json:"uptime_seconds"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Components map[string]*ComponentStatus `json:"components"`
|
||||
System *health.SystemInfo `json:"system,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Uptime float64 `json:"uptime_seconds"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Components map[string]*ComponentStatus `json:"components"`
|
||||
System *health.SystemInfo `json:"system,omitempty"`
|
||||
}
|
||||
|
||||
// ComponentStatus represents a component's health status
|
||||
@ -136,8 +136,8 @@ func ComponentHealthCheck(ctx *context.APIContext) {
|
||||
|
||||
if !found {
|
||||
ctx.JSON(http.StatusNotFound, map[string]any{
|
||||
"code": "COMPONENT_NOT_FOUND",
|
||||
"message": "Health check component not found",
|
||||
"code": "COMPONENT_NOT_FOUND",
|
||||
"message": "Health check component not found",
|
||||
"component": component,
|
||||
})
|
||||
return
|
||||
|
||||
@ -13,22 +13,22 @@ import (
|
||||
|
||||
// OperationProgressResponse represents an operation progress response
|
||||
type OperationProgressResponse struct {
|
||||
OperationID string `json:"operation_id"`
|
||||
Type string `json:"type"`
|
||||
Status string `json:"status"`
|
||||
CurrentPhase string `json:"current_phase,omitempty"`
|
||||
Phases []Phase `json:"phases,omitempty"`
|
||||
Progress int `json:"progress"`
|
||||
BytesTotal int64 `json:"bytes_total,omitempty"`
|
||||
BytesDone int64 `json:"bytes_done,omitempty"`
|
||||
ItemsTotal int `json:"items_total,omitempty"`
|
||||
ItemsDone int `json:"items_done,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
StartedAt string `json:"started_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
EstimatedETA string `json:"estimated_eta,omitempty"`
|
||||
SpeedBPS int64 `json:"speed_bps,omitempty"`
|
||||
OperationID string `json:"operation_id"`
|
||||
Type string `json:"type"`
|
||||
Status string `json:"status"`
|
||||
CurrentPhase string `json:"current_phase,omitempty"`
|
||||
Phases []Phase `json:"phases,omitempty"`
|
||||
Progress int `json:"progress"`
|
||||
BytesTotal int64 `json:"bytes_total,omitempty"`
|
||||
BytesDone int64 `json:"bytes_done,omitempty"`
|
||||
ItemsTotal int `json:"items_total,omitempty"`
|
||||
ItemsDone int `json:"items_done,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
StartedAt string `json:"started_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
EstimatedETA string `json:"estimated_eta,omitempty"`
|
||||
SpeedBPS int64 `json:"speed_bps,omitempty"`
|
||||
}
|
||||
|
||||
// Phase represents a phase in an operation
|
||||
|
||||
@ -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,11 +206,10 @@ func GetWikiPageV2(ctx *context.APIContext) {
|
||||
|
||||
// Render HTML
|
||||
var htmlContent string
|
||||
if rd, err := charset.ToUTF8Reader(nil, strings.NewReader(content)); err == nil {
|
||||
if buf := new(strings.Builder); buf != nil {
|
||||
if err := markdown.RenderWiki(ctx, markup.NewRenderContext(ctx).WithRelativePath(gitFilename), rd, buf); err == nil {
|
||||
htmlContent = buf.String()
|
||||
}
|
||||
rd := charset.ToUTF8WithFallbackReader(strings.NewReader(content), charset.ConvertOpts{})
|
||||
if buf := new(strings.Builder); buf != nil {
|
||||
if err := markdown.Render(markup.NewRenderContext(ctx).WithRelativePath(gitFilename), rd, buf); err == nil {
|
||||
htmlContent = buf.String()
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
wikiRepo, err := git.OpenRepository(ctx, wikiPath)
|
||||
wikiRepo, err := gitrepo.OpenRepository(ctx, repo.WikiStorageRepo())
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
return nil, nil, 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