summaryrefslogtreecommitdiffstats
path: root/modules/context/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/context/repo.go')
-rw-r--r--modules/context/repo.go93
1 files changed, 0 insertions, 93 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index b33341c245..84e07ab422 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -8,7 +8,6 @@ import (
"context"
"fmt"
"html"
- "io"
"net/http"
"net/url"
"path"
@@ -28,33 +27,12 @@ import (
"code.gitea.io/gitea/modules/log"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
- api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
asymkey_service "code.gitea.io/gitea/services/asymkey"
"github.com/editorconfig/editorconfig-core-go/v2"
- "gopkg.in/yaml.v3"
)
-// IssueTemplateDirCandidates issue templates directory
-var IssueTemplateDirCandidates = []string{
- "ISSUE_TEMPLATE",
- "issue_template",
- ".gitea/ISSUE_TEMPLATE",
- ".gitea/issue_template",
- ".github/ISSUE_TEMPLATE",
- ".github/issue_template",
- ".gitlab/ISSUE_TEMPLATE",
- ".gitlab/issue_template",
-}
-
-var IssueConfigCandidates = []string{
- ".gitea/ISSUE_TEMPLATE/config",
- ".gitea/issue_template/config",
- ".github/ISSUE_TEMPLATE/config",
- ".github/issue_template/config",
-}
-
// PullRequest contains information to make a pull request
type PullRequest struct {
BaseRepo *repo_model.Repository
@@ -1061,74 +1039,3 @@ func UnitTypes() func(ctx *Context) {
ctx.Data["UnitTypeActions"] = unit_model.TypeActions
}
}
-
-func GetDefaultIssueConfig() api.IssueConfig {
- return api.IssueConfig{
- BlankIssuesEnabled: true,
- ContactLinks: make([]api.IssueConfigContactLink, 0),
- }
-}
-
-// GetIssueConfig loads the given issue config file.
-// It never returns a nil config.
-func (r *Repository) GetIssueConfig(path string, commit *git.Commit) (api.IssueConfig, error) {
- if r.GitRepo == nil {
- return GetDefaultIssueConfig(), nil
- }
-
- var err error
-
- treeEntry, err := commit.GetTreeEntryByPath(path)
- if err != nil {
- return GetDefaultIssueConfig(), err
- }
-
- reader, err := treeEntry.Blob().DataAsync()
- if err != nil {
- log.Debug("DataAsync: %v", err)
- return GetDefaultIssueConfig(), nil
- }
-
- defer reader.Close()
-
- configContent, err := io.ReadAll(reader)
- if err != nil {
- return GetDefaultIssueConfig(), err
- }
-
- issueConfig := api.IssueConfig{}
- if err := yaml.Unmarshal(configContent, &issueConfig); err != nil {
- return GetDefaultIssueConfig(), err
- }
-
- for pos, link := range issueConfig.ContactLinks {
- if link.Name == "" {
- return GetDefaultIssueConfig(), fmt.Errorf("contact_link at position %d is missing name key", pos+1)
- }
-
- if link.URL == "" {
- return GetDefaultIssueConfig(), fmt.Errorf("contact_link at position %d is missing url key", pos+1)
- }
-
- if link.About == "" {
- return GetDefaultIssueConfig(), fmt.Errorf("contact_link at position %d is missing about key", pos+1)
- }
-
- _, err = url.ParseRequestURI(link.URL)
- if err != nil {
- return GetDefaultIssueConfig(), fmt.Errorf("%s is not a valid URL", link.URL)
- }
- }
-
- return issueConfig, nil
-}
-
-// IsIssueConfig returns if the given path is a issue config file.
-func (r *Repository) IsIssueConfig(path string) bool {
- for _, configName := range IssueConfigCandidates {
- if path == configName+".yaml" || path == configName+".yml" {
- return true
- }
- }
- return false
-}