mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-28 20:56:11 +01:00
Backport #31319 by @lunny Fix a hash render problem like `<hash>: xxxxx` which is usually used in release notes. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> (cherry picked from commit 6ca70c5bf20fc6b3a7d98d784f48b5a503962339)
This commit is contained in:
parent
3b4405aece
commit
5233f5f3e5
|
@ -48,7 +48,7 @@ var (
|
||||||
// hashCurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae
|
// hashCurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae
|
||||||
// Although SHA1 hashes are 40 chars long, SHA256 are 64, the regex matches the hash from 7 to 64 chars in length
|
// Although SHA1 hashes are 40 chars long, SHA256 are 64, the regex matches the hash from 7 to 64 chars in length
|
||||||
// so that abbreviated hash links can be used as well. This matches git and GitHub usability.
|
// so that abbreviated hash links can be used as well. This matches git and GitHub usability.
|
||||||
hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,](\s|$))`)
|
hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,:](\s|$))`)
|
||||||
|
|
||||||
// shortLinkPattern matches short but difficult to parse [[name|link|arg=test]] syntax
|
// shortLinkPattern matches short but difficult to parse [[name|link|arg=test]] syntax
|
||||||
shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`)
|
shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`)
|
||||||
|
|
|
@ -381,6 +381,7 @@ func TestRegExp_sha1CurrentPattern(t *testing.T) {
|
||||||
"(abcdefabcdefabcdefabcdefabcdefabcdefabcd)",
|
"(abcdefabcdefabcdefabcdefabcdefabcdefabcd)",
|
||||||
"[abcdefabcdefabcdefabcdefabcdefabcdefabcd]",
|
"[abcdefabcdefabcdefabcdefabcdefabcdefabcd]",
|
||||||
"abcdefabcdefabcdefabcdefabcdefabcdefabcd.",
|
"abcdefabcdefabcdefabcdefabcdefabcdefabcd.",
|
||||||
|
"abcdefabcdefabcdefabcdefabcdefabcdefabcd:",
|
||||||
}
|
}
|
||||||
falseTestCases := []string{
|
falseTestCases := []string{
|
||||||
"test",
|
"test",
|
||||||
|
|
Loading…
Reference in a new issue