mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-28 03:00:03 +02:00
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>
This commit is contained in:
parent
5f618248a9
commit
52c2e82813
13 changed files with 206 additions and 26 deletions
|
@ -351,6 +351,24 @@ func FindRenderizableReferenceNumeric(content string, prOnly bool) (bool, *Rende
|
|||
}
|
||||
}
|
||||
|
||||
// FindRenderizableReferenceRegexp returns the first regexp unvalidated references found in a string.
|
||||
func FindRenderizableReferenceRegexp(content string, pattern *regexp.Regexp) (bool, *RenderizableReference) {
|
||||
match := pattern.FindStringSubmatchIndex(content)
|
||||
if len(match) < 4 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
action, location := findActionKeywords([]byte(content), match[2])
|
||||
|
||||
return true, &RenderizableReference{
|
||||
Issue: content[match[2]:match[3]],
|
||||
RefLocation: &RefSpan{Start: match[0], End: match[1]},
|
||||
Action: action,
|
||||
ActionLocation: location,
|
||||
IsPull: false,
|
||||
}
|
||||
}
|
||||
|
||||
// FindRenderizableReferenceAlphanumeric returns the first alphanumeric unvalidated references found in a string.
|
||||
func FindRenderizableReferenceAlphanumeric(content string) (bool, *RenderizableReference) {
|
||||
match := issueAlphanumericPattern.FindStringSubmatchIndex(content)
|
||||
|
@ -547,7 +565,7 @@ func findActionKeywords(content []byte, start int) (XRefAction, *RefSpan) {
|
|||
}
|
||||
|
||||
// IsXrefActionable returns true if the xref action is actionable (i.e. produces a result when resolved)
|
||||
func IsXrefActionable(ref *RenderizableReference, extTracker, alphaNum bool) bool {
|
||||
func IsXrefActionable(ref *RenderizableReference, extTracker bool) bool {
|
||||
if extTracker {
|
||||
// External issues cannot be automatically closed
|
||||
return false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue