@@ -25,8 +25,8 @@ func alphanumIssueLink(baseURL, class, name string) string {
25
25
}
26
26
27
27
// numericLink an HTML to a numeric-style issue
28
- func numericIssueLink (baseURL , class string , index int ) string {
29
- return link (util .URLJoin (baseURL , strconv .Itoa (index )), class , fmt .Sprintf ("#%d" , index ))
28
+ func numericIssueLink (baseURL , class string , index int , marker string ) string {
29
+ return link (util .URLJoin (baseURL , strconv .Itoa (index )), class , fmt .Sprintf ("%s%d" , marker , index ))
30
30
}
31
31
32
32
// link an HTML link
@@ -75,8 +75,12 @@ func TestRender_IssueIndexPattern(t *testing.T) {
75
75
test ("#abcd" )
76
76
test ("test#1234" )
77
77
test ("#1234test" )
78
- test (" test #1234test" )
78
+ test ("#abcd" )
79
+ test ("test!1234" )
80
+ test ("!1234test" )
81
+ test (" test !1234test" )
79
82
test ("/home/gitea/#1234" )
83
+ test ("/home/gitea/!1234" )
80
84
81
85
// should not render issue mention without leading space
82
86
test ("test#54321 issue" )
@@ -90,42 +94,54 @@ func TestRender_IssueIndexPattern2(t *testing.T) {
90
94
setting .AppSubURL = AppSubURL
91
95
92
96
// numeric: render inputs with valid mentions
93
- test := func (s , expectedFmt string , indices ... int ) {
97
+ test := func (s , expectedFmt , marker string , indices ... int ) {
98
+ var path , prefix string
99
+ if marker == "!" {
100
+ path = "pulls"
101
+ prefix = "http://localhost:3000/someUser/someRepo/pulls/"
102
+ } else {
103
+ path = "issues"
104
+ prefix = "https://someurl.com/someUser/someRepo/"
105
+ }
106
+
94
107
links := make ([]interface {}, len (indices ))
95
108
for i , index := range indices {
96
- links [i ] = numericIssueLink (util .URLJoin (setting .AppSubURL , "issues" ), "issue" , index )
109
+ links [i ] = numericIssueLink (util .URLJoin (setting .AppSubURL , path ), "issue" , index , marker )
97
110
}
98
111
expectedNil := fmt .Sprintf (expectedFmt , links ... )
99
112
testRenderIssueIndexPattern (t , s , expectedNil , & postProcessCtx {metas : localMetas })
100
113
101
114
for i , index := range indices {
102
- links [i ] = numericIssueLink ("https://someurl.com/someUser/someRepo/" , "issue" , index )
115
+ links [i ] = numericIssueLink (prefix , "issue" , index , marker )
103
116
}
104
117
expectedNum := fmt .Sprintf (expectedFmt , links ... )
105
118
testRenderIssueIndexPattern (t , s , expectedNum , & postProcessCtx {metas : numericMetas })
106
119
}
107
120
108
121
// should render freestanding mentions
109
- test ("#1234 test" , "%s test" , 1234 )
110
- test ("test #8 issue" , "test %s issue" , 8 )
111
- test ("test issue #1234" , "test issue %s" , 1234 )
112
- test ("fixes issue #1234." , "fixes issue %s." , 1234 )
122
+ test ("#1234 test" , "%s test" , "#" , 1234 )
123
+ test ("test #8 issue" , "test %s issue" , "#" , 8 )
124
+ test ("!1234 test" , "%s test" , "!" , 1234 )
125
+ test ("test !8 issue" , "test %s issue" , "!" , 8 )
126
+ test ("test issue #1234" , "test issue %s" , "#" , 1234 )
127
+ test ("fixes issue #1234." , "fixes issue %s." , "#" , 1234 )
113
128
114
129
// should render mentions in parentheses / brackets
115
- test ("(#54321 issue)" , "(%s issue)" , 54321 )
116
- test ("[#54321 issue]" , "[%s issue]" , 54321 )
117
- test ("test (#9801 extra) issue" , "test (%s extra) issue" , 9801 )
118
- test ("test (#1)" , "test (%s)" , 1 )
130
+ test ("(#54321 issue)" , "(%s issue)" , "#" , 54321 )
131
+ test ("[#54321 issue]" , "[%s issue]" , "#" , 54321 )
132
+ test ("test (#9801 extra) issue" , "test (%s extra) issue" , "#" , 9801 )
133
+ test ("test (!9801 extra) issue" , "test (%s extra) issue" , "!" , 9801 )
134
+ test ("test (#1)" , "test (%s)" , "#" , 1 )
119
135
120
136
// should render multiple issue mentions in the same line
121
- test ("#54321 #1243" , "%s %s" , 54321 , 1243 )
122
- test ("wow (#54321 #1243)" , "wow (%s %s)" , 54321 , 1243 )
123
- test ("(#4)(#5)" , "(%s)(%s)" , 4 , 5 )
124
- test ("#1 (#4321) test" , "%s (%s) test" , 1 , 4321 )
137
+ test ("#54321 #1243" , "%s %s" , "#" , 54321 , 1243 )
138
+ test ("wow (#54321 #1243)" , "wow (%s %s)" , "#" , 54321 , 1243 )
139
+ test ("(#4)(#5)" , "(%s)(%s)" , "#" , 4 , 5 )
140
+ test ("#1 (#4321) test" , "%s (%s) test" , "#" , 1 , 4321 )
125
141
126
142
// should render with :
127
- test ("#1234: test" , "%s: test" , 1234 )
128
- test ("wow (#54321: test)" , "wow (%s: test)" , 54321 )
143
+ test ("#1234: test" , "%s: test" , "#" , 1234 )
144
+ test ("wow (#54321: test)" , "wow (%s: test)" , "#" , 54321 )
129
145
}
130
146
131
147
func TestRender_IssueIndexPattern3 (t * testing.T ) {
@@ -201,7 +217,7 @@ func TestRender_AutoLink(t *testing.T) {
201
217
202
218
// render valid issue URLs
203
219
test (util .URLJoin (setting .AppSubURL , "issues" , "3333" ),
204
- numericIssueLink (util .URLJoin (setting .AppSubURL , "issues" ), "issue" , 3333 ))
220
+ numericIssueLink (util .URLJoin (setting .AppSubURL , "issues" ), "issue" , 3333 , "#" ))
205
221
206
222
// render valid commit URLs
207
223
tmp := util .URLJoin (AppSubURL , "commit" , "d8a994ef243349f321568f9e36d5c3f444b99cae" )
0 commit comments