Skip to content

Commit d3be0fb

Browse files
committed
Merge branch 'main' into lunny/uniform-temp-dir
2 parents 85d5fc6 + e1c2d05 commit d3be0fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+578
-380
lines changed

custom/conf/app.example.ini

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,14 +1401,14 @@ LEVEL = Info
14011401
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14021402
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14031403
;;
1404-
;; Render soft line breaks as hard line breaks, which means a single newline character between
1405-
;; paragraphs will cause a line break and adding trailing whitespace to paragraphs is not
1406-
;; necessary to force a line break.
1407-
;; Render soft line breaks as hard line breaks for comments
1408-
;ENABLE_HARD_LINE_BREAK_IN_COMMENTS = true
1409-
;;
1410-
;; Render soft line breaks as hard line breaks for markdown documents
1411-
;ENABLE_HARD_LINE_BREAK_IN_DOCUMENTS = false
1404+
;; Customize render options for different contexts. Set to "none" to disable the defaults, or use comma separated list:
1405+
;; * short-issue-pattern: recognized "#123" issue reference and render it as a link to the issue
1406+
;; * new-line-hard-break: render soft line breaks as hard line breaks, which means a single newline character between
1407+
;; paragraphs will cause a line break and adding trailing whitespace to paragraphs is not
1408+
;; necessary to force a line break.
1409+
;RENDER_OPTIONS_COMMENT = short-issue-pattern, new-line-hard-break
1410+
;RENDER_OPTIONS_WIKI = short-issue-pattern
1411+
;RENDER_OPTIONS_REPO_FILE =
14121412
;;
14131413
;; Comma separated list of custom URL-Schemes that are allowed as links when rendering Markdown
14141414
;; for example git,magnet,ftp (more at https://en.wikipedia.org/wiki/List_of_URI_schemes)
@@ -1422,6 +1422,12 @@ LEVEL = Info
14221422
;;
14231423
;; Enables math inline and block detection
14241424
;ENABLE_MATH = true
1425+
;;
1426+
;; Enable delimiters for math code block detection. Set to "none" to disable all,
1427+
;; or use comma separated list: inline-dollar, inline-parentheses, block-dollar, block-square-brackets
1428+
;; Defaults to "inline-dollar,block-dollar" to follow GitHub's behavior.
1429+
;MATH_CODE_BLOCK_DETECTION =
1430+
;;
14251431

14261432
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14271433
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

models/renderhelper/repo_comment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ func NewRenderContextRepoComment(ctx context.Context, repo *repo_model.Repositor
5656
if repo != nil {
5757
helper.repoLink = repo.Link()
5858
helper.commitChecker = newCommitChecker(ctx, repo)
59-
rctx = rctx.WithMetas(repo.ComposeMetas(ctx))
59+
rctx = rctx.WithMetas(repo.ComposeCommentMetas(ctx))
6060
} else {
6161
// this is almost dead code, only to pass the incorrect tests
6262
helper.repoLink = fmt.Sprintf("%s/%s", helper.opts.DeprecatedOwnerName, helper.opts.DeprecatedRepoName)
6363
rctx = rctx.WithMetas(map[string]string{
6464
"user": helper.opts.DeprecatedOwnerName,
6565
"repo": helper.opts.DeprecatedRepoName,
6666

67-
"markdownLineBreakStyle": "comment",
67+
"markdownNewLineHardBreak": "true",
6868
"markupAllowShortIssuePattern": "true",
6969
})
7070
}

models/renderhelper/repo_file.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,13 @@ func NewRenderContextRepoFile(ctx context.Context, repo *repo_model.Repository,
6161
if repo != nil {
6262
helper.repoLink = repo.Link()
6363
helper.commitChecker = newCommitChecker(ctx, repo)
64-
rctx = rctx.WithMetas(repo.ComposeDocumentMetas(ctx))
64+
rctx = rctx.WithMetas(repo.ComposeRepoFileMetas(ctx))
6565
} else {
6666
// this is almost dead code, only to pass the incorrect tests
6767
helper.repoLink = fmt.Sprintf("%s/%s", helper.opts.DeprecatedOwnerName, helper.opts.DeprecatedRepoName)
6868
rctx = rctx.WithMetas(map[string]string{
6969
"user": helper.opts.DeprecatedOwnerName,
7070
"repo": helper.opts.DeprecatedRepoName,
71-
72-
"markdownLineBreakStyle": "document",
7371
})
7472
}
7573
rctx = rctx.WithHelper(helper)

models/renderhelper/repo_wiki.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func NewRenderContextRepoWiki(ctx context.Context, repo *repo_model.Repository,
6868
"user": helper.opts.DeprecatedOwnerName,
6969
"repo": helper.opts.DeprecatedRepoName,
7070

71-
"markdownLineBreakStyle": "document",
7271
"markupAllowShortIssuePattern": "true",
7372
})
7473
}

models/repo/repo.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,15 @@ func (repo *Repository) composeCommonMetas(ctx context.Context) map[string]strin
512512
"repo": repo.Name,
513513
}
514514

515-
unit, err := repo.GetUnit(ctx, unit.TypeExternalTracker)
515+
unitExternalTracker, err := repo.GetUnit(ctx, unit.TypeExternalTracker)
516516
if err == nil {
517-
metas["format"] = unit.ExternalTrackerConfig().ExternalTrackerFormat
518-
switch unit.ExternalTrackerConfig().ExternalTrackerStyle {
517+
metas["format"] = unitExternalTracker.ExternalTrackerConfig().ExternalTrackerFormat
518+
switch unitExternalTracker.ExternalTrackerConfig().ExternalTrackerStyle {
519519
case markup.IssueNameStyleAlphanumeric:
520520
metas["style"] = markup.IssueNameStyleAlphanumeric
521521
case markup.IssueNameStyleRegexp:
522522
metas["style"] = markup.IssueNameStyleRegexp
523-
metas["regexp"] = unit.ExternalTrackerConfig().ExternalTrackerRegexpPattern
523+
metas["regexp"] = unitExternalTracker.ExternalTrackerConfig().ExternalTrackerRegexpPattern
524524
default:
525525
metas["style"] = markup.IssueNameStyleNumeric
526526
}
@@ -544,28 +544,29 @@ func (repo *Repository) composeCommonMetas(ctx context.Context) map[string]strin
544544
return repo.commonRenderingMetas
545545
}
546546

547-
// ComposeMetas composes a map of metas for properly rendering comments or comment-like contents (commit message)
548-
func (repo *Repository) ComposeMetas(ctx context.Context) map[string]string {
547+
// ComposeCommentMetas composes a map of metas for properly rendering comments or comment-like contents (commit message)
548+
func (repo *Repository) ComposeCommentMetas(ctx context.Context) map[string]string {
549549
metas := maps.Clone(repo.composeCommonMetas(ctx))
550-
metas["markdownLineBreakStyle"] = "comment"
551-
metas["markupAllowShortIssuePattern"] = "true"
550+
metas["markdownNewLineHardBreak"] = strconv.FormatBool(setting.Markdown.RenderOptionsComment.NewLineHardBreak)
551+
metas["markupAllowShortIssuePattern"] = strconv.FormatBool(setting.Markdown.RenderOptionsComment.ShortIssuePattern)
552552
return metas
553553
}
554554

555555
// ComposeWikiMetas composes a map of metas for properly rendering wikis
556556
func (repo *Repository) ComposeWikiMetas(ctx context.Context) map[string]string {
557557
// does wiki need the "teams" and "org" from common metas?
558558
metas := maps.Clone(repo.composeCommonMetas(ctx))
559-
metas["markdownLineBreakStyle"] = "document"
560-
metas["markupAllowShortIssuePattern"] = "true"
559+
metas["markdownNewLineHardBreak"] = strconv.FormatBool(setting.Markdown.RenderOptionsWiki.NewLineHardBreak)
560+
metas["markupAllowShortIssuePattern"] = strconv.FormatBool(setting.Markdown.RenderOptionsWiki.ShortIssuePattern)
561561
return metas
562562
}
563563

564-
// ComposeDocumentMetas composes a map of metas for properly rendering documents (repo files)
565-
func (repo *Repository) ComposeDocumentMetas(ctx context.Context) map[string]string {
564+
// ComposeRepoFileMetas composes a map of metas for properly rendering documents (repo files)
565+
func (repo *Repository) ComposeRepoFileMetas(ctx context.Context) map[string]string {
566566
// does document(file) need the "teams" and "org" from common metas?
567567
metas := maps.Clone(repo.composeCommonMetas(ctx))
568-
metas["markdownLineBreakStyle"] = "document"
568+
metas["markdownNewLineHardBreak"] = strconv.FormatBool(setting.Markdown.RenderOptionsRepoFile.NewLineHardBreak)
569+
metas["markupAllowShortIssuePattern"] = strconv.FormatBool(setting.Markdown.RenderOptionsRepoFile.ShortIssuePattern)
569570
return metas
570571
}
571572

models/repo/repo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestMetas(t *testing.T) {
8686

8787
repo.Units = nil
8888

89-
metas := repo.ComposeMetas(db.DefaultContext)
89+
metas := repo.ComposeCommentMetas(db.DefaultContext)
9090
assert.Equal(t, "testRepo", metas["repo"])
9191
assert.Equal(t, "testOwner", metas["user"])
9292

@@ -100,7 +100,7 @@ func TestMetas(t *testing.T) {
100100
testSuccess := func(expectedStyle string) {
101101
repo.Units = []*RepoUnit{&externalTracker}
102102
repo.commonRenderingMetas = nil
103-
metas := repo.ComposeMetas(db.DefaultContext)
103+
metas := repo.ComposeCommentMetas(db.DefaultContext)
104104
assert.Equal(t, expectedStyle, metas["style"])
105105
assert.Equal(t, "testRepo", metas["repo"])
106106
assert.Equal(t, "testOwner", metas["user"])
@@ -121,7 +121,7 @@ func TestMetas(t *testing.T) {
121121
repo, err := GetRepositoryByID(db.DefaultContext, 3)
122122
assert.NoError(t, err)
123123

124-
metas = repo.ComposeMetas(db.DefaultContext)
124+
metas = repo.ComposeCommentMetas(db.DefaultContext)
125125
assert.Contains(t, metas, "org")
126126
assert.Contains(t, metas, "teams")
127127
assert.Equal(t, "org3", metas["org"])

modules/git/repo_commit_nogogit.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ func (repo *Repository) getCommit(id ObjectID) (*Commit, error) {
8181

8282
_, _ = wr.Write([]byte(id.String() + "\n"))
8383

84-
return repo.getCommitFromBatchReader(rd, id)
84+
return repo.getCommitFromBatchReader(wr, rd, id)
8585
}
8686

87-
func (repo *Repository) getCommitFromBatchReader(rd *bufio.Reader, id ObjectID) (*Commit, error) {
87+
func (repo *Repository) getCommitFromBatchReader(wr WriteCloserError, rd *bufio.Reader, id ObjectID) (*Commit, error) {
8888
_, typ, size, err := ReadBatchLine(rd)
8989
if err != nil {
9090
if errors.Is(err, io.EOF) || IsErrNotExist(err) {
@@ -112,7 +112,11 @@ func (repo *Repository) getCommitFromBatchReader(rd *bufio.Reader, id ObjectID)
112112
return nil, err
113113
}
114114

115-
commit, err := tag.Commit(repo)
115+
if _, err := wr.Write([]byte(tag.Object.String() + "\n")); err != nil {
116+
return nil, err
117+
}
118+
119+
commit, err := repo.getCommitFromBatchReader(wr, rd, tag.Object)
116120
if err != nil {
117121
return nil, err
118122
}

modules/git/repo_tag_nogogit.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ func (repo *Repository) GetTagType(id ObjectID) (string, error) {
4141
return "", err
4242
}
4343
_, typ, _, err := ReadBatchLine(rd)
44-
if IsErrNotExist(err) {
45-
return "", ErrNotExist{ID: id.String()}
44+
if err != nil {
45+
if IsErrNotExist(err) {
46+
return "", ErrNotExist{ID: id.String()}
47+
}
48+
return "", err
4649
}
4750
return typ, nil
4851
}

modules/git/repo_tree_nogogit.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ func (repo *Repository) getTree(id ObjectID) (*Tree, error) {
3535
if err != nil {
3636
return nil, err
3737
}
38-
commit, err := tag.Commit(repo)
38+
39+
if _, err := wr.Write([]byte(tag.Object.String() + "\n")); err != nil {
40+
return nil, err
41+
}
42+
commit, err := repo.getCommitFromBatchReader(wr, rd, tag.Object)
3943
if err != nil {
4044
return nil, err
4145
}

modules/git/tag.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ type Tag struct {
2121
Signature *CommitSignature
2222
}
2323

24-
// Commit return the commit of the tag reference
25-
func (tag *Tag) Commit(gitRepo *Repository) (*Commit, error) {
26-
return gitRepo.getCommit(tag.Object)
27-
}
28-
2924
func parsePayloadSignature(data []byte, messageStart int) (payload, msg, sign string) {
3025
pos := messageStart
3126
signStart, signEnd := -1, -1

0 commit comments

Comments
 (0)