Skip to content

Commit 42a57bf

Browse files
committed
fine tune variable name and comments
1 parent 4919558 commit 42a57bf

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

modules/markup/html.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ var filesChangedFullPatternOnce sync.Once
106106

107107
func getIssueFullPattern() *regexp.Regexp {
108108
issueFullPatternOnce.Do(func() {
109+
// example: https://domain/org/repo/pulls/27#hash
109110
issueFullPattern = regexp.MustCompile(regexp.QuoteMeta(setting.AppURL) +
110111
`[\w_.-]+/[\w_.-]+/(?:issues|pulls)/((?:\w{1,10}-)?[1-9][0-9]*)([\?|#](\S+)?)?\b`)
111112
})
@@ -114,6 +115,7 @@ func getIssueFullPattern() *regexp.Regexp {
114115

115116
func getFilesChangedFullPattern() *regexp.Regexp {
116117
filesChangedFullPatternOnce.Do(func() {
118+
// example: https://domain/org/repo/pulls/27/files#hash
117119
filesChangedFullPattern = regexp.MustCompile(regexp.QuoteMeta(setting.AppURL) +
118120
`[\w_.-]+/[\w_.-]+/pulls/((?:\w{1,10}-)?[1-9][0-9]*)/files([\?|#](\S+)?)?\b`)
119121
})
@@ -816,15 +818,13 @@ func fullIssuePatternProcessor(ctx *RenderContext, node *html.Node) {
816818
}
817819

818820
mDiffView := getFilesChangedFullPattern().FindStringSubmatchIndex(node.Data)
819-
// if the link is from "Files Changed" tab in pull requests https://domain/org/repo/pulls/27/files (aka: the files diff view)
820-
// leave it as it is
821+
// leave it as it is if the link is from "Files Changed" tab in PR Diff View https://domain/org/repo/pulls/27/files
821822
if mDiffView != nil {
822823
return
823824
}
824825

825826
link := node.Data[m[0]:m[1]]
826-
id := "#" + node.Data[m[2]:m[3]]
827-
text := id
827+
text := "#" + node.Data[m[2]:m[3]]
828828
// if m[4] and m[5] is not -1, then link is to a comment
829829
// indicate that in the text by appending (comment)
830830
if m[4] != -1 && m[5] != -1 {

web_src/js/features/comp/MarkupContentPreview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import $ from 'jquery';
22
import {initMarkupContent} from '../../markup/content.js';
3-
import {attachTippyToRefIssues} from '../contextpopup.js';
3+
import {attachRefIssueContextPopup} from '../contextpopup.js';
44

55
const {csrfToken} = window.config;
66

@@ -18,7 +18,7 @@ export function initCompMarkupContentPreviewTab($form) {
1818
const $previewPanel = $form.find(`.tab[data-tab="${$tabMenu.data('preview')}"]`);
1919
$previewPanel.html(data);
2020
const refIssues = $previewPanel.find('p .ref-issue');
21-
attachTippyToRefIssues(refIssues);
21+
attachRefIssueContextPopup(refIssues);
2222
initMarkupContent();
2323
});
2424
});

web_src/js/features/contextpopup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {createTippy} from '../modules/tippy.js';
66

77
export function initContextPopups() {
88
const refIssues = $('.ref-issue');
9-
attachTippyToRefIssues(refIssues);
9+
attachRefIssueContextPopup(refIssues);
1010
}
1111

12-
export function attachTippyToRefIssues(refIssues) {
12+
export function attachRefIssueContextPopup(refIssues) {
1313
if (!refIssues.length) return;
1414
refIssues.each(function () {
1515
if ($(this).hasClass('ref-external-issue')) {

web_src/js/features/repo-legacy.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {initCompReactionSelector} from './comp/ReactionSelector.js';
2626
import {initRepoSettingBranches} from './repo-settings.js';
2727
import {initRepoPullRequestMergeForm} from './repo-issue-pr-form.js';
2828
import {hideElem, showElem} from '../utils/dom.js';
29-
import {attachTippyToRefIssues} from './contextpopup.js';
29+
import {attachRefIssueContextPopup} from './contextpopup.js';
3030

3131
const {csrfToken} = window.config;
3232

@@ -440,10 +440,8 @@ async function onEditContent(event) {
440440
} else {
441441
$renderContent.html(data.content);
442442
$rawContent.text($textarea.val());
443-
// check if the content contains ref-issue
444-
// if there are ref issues, attach the tippy
445443
const refIssues = $renderContent.find('p .ref-issue');
446-
attachTippyToRefIssues(refIssues);
444+
attachRefIssueContextPopup(refIssues);
447445
}
448446
const $content = $segment;
449447
if (!$content.find('.dropzone-attachments').length) {

0 commit comments

Comments
 (0)