Files
MokoGitea/services/markup/renderhelper_issueicontitle.go
T
Jonathan Miller c572fcfe04
PR RC Release / Build RC Release (pull_request) Failing after 0s
Branch Policy Check / Verify merge target (pull_request) Failing after 0s
chore(core): rename Go module from code.gitea.io/gitea to MokoGitea namespace
Rename the Go module path from code.gitea.io/gitea to
git.mokoconsulting.tech/MokoConsulting/MokoGitea across the entire
codebase.

Scope:
- go.mod module declaration
- 2,235 Go source files (import paths)
- Dockerfile WORKDIR and COPY paths
- Swagger API templates
- golangci.yml linter config

External dependencies (code.gitea.io/gitea-vet, code.gitea.io/sdk/gitea,
gitea.com/gitea/act, etc.) are intentionally NOT renamed — they are
separate upstream modules.

Closes #132

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-25 00:22:38 -05:00

68 lines
1.9 KiB
Go

// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package markup
import (
"context"
"errors"
"fmt"
"html/template"
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/issues"
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/perm/access"
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/repo"
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/htmlutil"
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/markup"
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/util"
gitea_context "git.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context"
)
func renderRepoIssueIconTitle(ctx context.Context, opts markup.RenderIssueIconTitleOptions) (_ template.HTML, err error) {
webCtx := gitea_context.GetWebContext(ctx)
if webCtx == nil {
return "", errors.New("context is not a web context")
}
textIssueIndex := fmt.Sprintf("(#%d)", opts.IssueIndex)
dbRepo := webCtx.Repo.Repository
if opts.OwnerName != "" {
dbRepo, err = repo.GetRepositoryByOwnerAndName(ctx, opts.OwnerName, opts.RepoName)
if err != nil {
return "", err
}
textIssueIndex = fmt.Sprintf("(%s/%s#%d)", dbRepo.OwnerName, dbRepo.Name, opts.IssueIndex)
}
if dbRepo == nil {
return "", nil
}
issue, err := issues.GetIssueByIndex(ctx, dbRepo.ID, opts.IssueIndex)
if err != nil {
return "", err
}
if webCtx.Repo.Repository == nil || dbRepo.ID != webCtx.Repo.Repository.ID {
perms, err := access.GetDoerRepoPermission(ctx, dbRepo, webCtx.Doer)
if err != nil {
return "", err
}
if !perms.CanReadIssuesOrPulls(issue.IsPull) {
return "", util.ErrPermissionDenied
}
}
if issue.IsPull {
if err = issue.LoadPullRequest(ctx); err != nil {
return "", err
}
}
htmlIcon, err := webCtx.RenderToHTML("shared/issueicon", issue)
if err != nil {
return "", err
}
return htmlutil.HTMLFormat(`<a href="%s">%s %s %s</a>`, opts.LinkHref, htmlIcon, issue.Title, textIssueIndex), nil
}