Skip to content

Commit fc1401a

Browse files
committed
Fix syntax/style
1 parent 6808b57 commit fc1401a

File tree

5 files changed

+23
-27
lines changed

5 files changed

+23
-27
lines changed

modules/markup/html.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
const (
3434
IssueNameStyleNumeric = "numeric"
3535
IssueNameStyleAlphanumeric = "alphanumeric"
36-
IssueNameStyleRegexp = "regexp"
36+
IssueNameStyleRegexp = "regexp"
3737
)
3838

3939
var (
@@ -818,14 +818,14 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
818818
found = foundNumeric
819819
ref = refNumeric
820820
case IssueNameStyleAlphanumeric:
821-
found, ref := references.FindRenderizableReferenceAlphanumeric(node.Data)
821+
found, ref = references.FindRenderizableReferenceAlphanumeric(node.Data)
822822
case IssueNameStyleRegexp:
823823
// TODO: Compile only once, at regexp definition time
824-
pattern, err := regexp.Compile(ctx.metas["regexp"])
824+
pattern, err := regexp.Compile(ctx.Metas["regexp"])
825825
if err == nil {
826826
return
827827
}
828-
found, ref := references.FindRenderizableReferenceRegexp(node.Data, pattern)
828+
found, ref = references.FindRenderizableReferenceRegexp(node.Data, pattern)
829829
}
830830

831831
// Repos with external issue trackers might still need to reference local PRs

modules/markup/html_internal_test.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -207,40 +207,36 @@ func TestRender_IssueIndexPattern5(t *testing.T) {
207207
setting.AppSubURL = AppSubURL
208208

209209
// regexp: render inputs without valid mentions
210-
test := func(s, expectedFmt string, pattern string, ids []string, names []string) {
211-
metas := regexpMetas
212-
metas["regexp"] = pattern
213-
links := make([]interface{}, len(ids))
214-
for i, id := range ids {
215-
links[i] = link(util.URLJoin("https://someurl.com/someUser/someRepo/", id), names[i])
210+
test := func(s, expectedFmt string, pattern string, names []string) {
211+
links := make([]interface{}, len(names))
212+
for i, name := range names {
213+
// TODO: rename alphanumIssueLink to externalIssueLink
214+
links[i] = alphanumIssueLink("https://someurl.com/someUser/someRepo/", "ref-issue ref-external-issue", name)
216215
}
217216

218217
expected := fmt.Sprintf(expectedFmt, links...)
219-
testRenderIssueIndexPattern(t, s, expected, &postProcessCtx{metas: metas})
218+
testRenderIssueIndexPattern(t, s, expected, &RenderContext{Metas: regexpMetas})
220219
}
221220

222-
test("abc ISSUE-123 def", "abc %s def", "ISSUE-(\\d+)",
223-
[]string{"123"},
221+
test("abc ISSUE-123 def", "abc %s def",
222+
"ISSUE-(\\d+)",
224223
[]string{"ISSUE-123"},
225224
)
226225

227226
test("abc (ISSUE 123) def", "abc %s def",
228227
"\\(ISSUE (\\d+)\\)",
229-
[]string{"123"},
230228
[]string{"(ISSUE 123)"},
231229
)
232230

233231
test("abc (ISSUE 123) def (TASK 456) ghi", "abc %s def %s ghi", "\\((?:ISSUE|TASK) (\\d+)\\)",
234-
[]string{"123", "456"},
235232
[]string{"(ISSUE 123)", "(TASK 456)"},
236233
)
237234

238235
metas := regexpMetas
239236
metas["regexp"] = "no matches"
240-
testRenderIssueIndexPattern(t, "will not match", "will not match", &postProcessCtx{metas: metas})
237+
testRenderIssueIndexPattern(t, "will not match", "will not match", &RenderContext{Metas: regexpMetas})
241238
}
242239

243-
244240
func testRenderIssueIndexPattern(t *testing.T, input, expected string, ctx *RenderContext) {
245241
if ctx.URLPrefix == "" {
246242
ctx.URLPrefix = AppSubURL

modules/references/references.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func FindRenderizableReferenceNumeric(content string, prOnly bool) (bool, *Rende
341341
}
342342

343343
// FindRenderizableReferenceRegexp returns the first regexp unvalidated references found in a string.
344-
func FindRenderizableReferenceRegexp(content string, pattern *Regexp) (bool, *RenderizableReference) {
344+
func FindRenderizableReferenceRegexp(content string, pattern *regexp.Regexp) (bool, *RenderizableReference) {
345345
match := pattern.FindStringSubmatchIndex(content)
346346
if match == nil {
347347
return false, nil

services/forms/repo_form.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ type RepoSettingForm struct {
140140
ExternalTrackerURL string
141141
TrackerURLFormat string
142142
TrackerIssueStyle string
143-
ExternalTrackerRegexpPattern string
143+
ExternalTrackerRegexpPattern string
144144
EnableCloseIssuesViaCommitInAnyBranch bool
145145
EnableProjects bool
146146
EnablePulls bool

web_src/js/features/repo-legacy.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ export function initRepository() {
309309
if (typeof $(this).data('context') !== 'undefined') $($(this).data('context')).addClass('disabled');
310310
}
311311
});
312-
$('.enable-system-pick').change(function () {
313-
if ($(this).data('context') && $(this).data('target')) {
314-
if ($(this).data('context') === this.value) {
315-
$($(this).data('target')).removeClass('disabled')
316-
} else {
317-
$($(this).data('target')).addClass('disabled')
318-
}
312+
$('.enable-system-pick').on('change', function () {
313+
if ($(this).data('context') && $(this).data('target')) {
314+
if ($(this).data('context') === this.value) {
315+
$($(this).data('target')).removeClass('disabled');
316+
} else {
317+
$($(this).data('target')).addClass('disabled');
319318
}
320-
})
319+
}
320+
});
321321
}
322322

323323
// Labels

0 commit comments

Comments
 (0)