This repository has been archived on 2022-12-27. You can view files and clone it, but cannot push or open issues or pull requests.
postea/pulls/pulls.go
jolheiser ff459cacba
Remove tea and add changelog search
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2022-06-21 10:21:43 -05:00

25 lines
477 B
Go

package pulls
import (
"io"
"regexp"
)
var (
pullGiteaURL = "https://github.com/go-gitea/gitea/pull/"
pullRegex = regexp.MustCompile(`#(\d+)\)`)
)
// Format formats input by replacing pull refs #1234 with markdown links [#1234](...pull/1234)
func Format(r io.Reader) ([]byte, error) {
data, err := io.ReadAll(r)
if err != nil {
return nil, err
}
pullURL := pullGiteaURL
repl := pullRegex.ReplaceAll(data, []byte(`[#$1](`+pullURL+`$1))`))
return repl, nil
}