summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorSandro Santilli <strk@kbt.io>2022-06-10 07:39:53 +0200
committerGitHub <noreply@github.com>2022-06-10 13:39:53 +0800
commit52c2e82813c2519cd08c9ecd66ef7b0815682770 (patch)
tree1120ca6d9b6534e33554f0b1c74529e62feba5b2 /models
parent5f618248a98ffbb7066100ffe1955faf791d0205 (diff)
downloadgitea-52c2e82813c2519cd08c9ecd66ef7b0815682770.tar.gz
gitea-52c2e82813c2519cd08c9ecd66ef7b0815682770.zip
Custom regexp external issues (#17624)
* Implement custom regular expression for external issue tracking. Signed-off-by: Alexander Beyn <malex@fatelectrons.org> * Fix syntax/style * Update repo.go * Set metas['regexp'] * gofmt * fix some tests * fix more tests * refactor frontend * use LRU cache for regexp * Update modules/markup/html_internal_test.go Co-authored-by: Alexander Beyn <malex@fatelectrons.org> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models')
-rw-r--r--models/repo/repo.go3
-rw-r--r--models/repo/repo_unit.go7
-rw-r--r--models/repo_test.go3
3 files changed, 10 insertions, 3 deletions
diff --git a/models/repo/repo.go b/models/repo/repo.go
index 3fd6b94eb1..57d85435eb 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -414,6 +414,9 @@ func (repo *Repository) ComposeMetas() map[string]string {
switch unit.ExternalTrackerConfig().ExternalTrackerStyle {
case markup.IssueNameStyleAlphanumeric:
metas["style"] = markup.IssueNameStyleAlphanumeric
+ case markup.IssueNameStyleRegexp:
+ metas["style"] = markup.IssueNameStyleRegexp
+ metas["regexp"] = unit.ExternalTrackerConfig().ExternalTrackerRegexpPattern
default:
metas["style"] = markup.IssueNameStyleNumeric
}
diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go
index 8c17d6138c..da3e19dece 100644
--- a/models/repo/repo_unit.go
+++ b/models/repo/repo_unit.go
@@ -76,9 +76,10 @@ func (cfg *ExternalWikiConfig) ToDB() ([]byte, error) {
// ExternalTrackerConfig describes external tracker config
type ExternalTrackerConfig struct {
- ExternalTrackerURL string
- ExternalTrackerFormat string
- ExternalTrackerStyle string
+ ExternalTrackerURL string
+ ExternalTrackerFormat string
+ ExternalTrackerStyle string
+ ExternalTrackerRegexpPattern string
}
// FromDB fills up a ExternalTrackerConfig from serialized format.
diff --git a/models/repo_test.go b/models/repo_test.go
index c9e66398d1..f554ff16a6 100644
--- a/models/repo_test.go
+++ b/models/repo_test.go
@@ -74,6 +74,9 @@ func TestMetas(t *testing.T) {
externalTracker.ExternalTrackerConfig().ExternalTrackerStyle = markup.IssueNameStyleNumeric
testSuccess(markup.IssueNameStyleNumeric)
+ externalTracker.ExternalTrackerConfig().ExternalTrackerStyle = markup.IssueNameStyleRegexp
+ testSuccess(markup.IssueNameStyleRegexp)
+
repo, err := repo_model.GetRepositoryByID(3)
assert.NoError(t, err)