Skip to content

Commit 74ed0fe

Browse files
authored
Merge branch 'master' into enh/noid/commit-message-link-check-commit-hashes
2 parents 663bc8e + 1d8915a commit 74ed0fe

File tree

6 files changed

+115
-41
lines changed

6 files changed

+115
-41
lines changed

models/issue_comment.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ const (
9999

100100
// Comment represents a comment in commit and issue page.
101101
type Comment struct {
102-
ID int64 `xorm:"pk autoincr"`
103-
Type CommentType
104-
PosterID int64 `xorm:"INDEX"`
105-
Poster *User `xorm:"-"`
102+
ID int64 `xorm:"pk autoincr"`
103+
Type CommentType `xorm:"index"`
104+
PosterID int64 `xorm:"INDEX"`
105+
Poster *User `xorm:"-"`
106106
OriginalAuthor string
107107
OriginalAuthorID int64
108108
IssueID int64 `xorm:"INDEX"`
@@ -143,7 +143,7 @@ type Comment struct {
143143
ShowTag CommentTag `xorm:"-"`
144144

145145
Review *Review `xorm:"-"`
146-
ReviewID int64
146+
ReviewID int64 `xorm:"index"`
147147
Invalidated bool
148148
}
149149

models/migrations/migrations.go

+2
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ var migrations = []Migration{
236236
NewMigration("add original author/url migration info to issues, comments, and repo ", addOriginalMigrationInfo),
237237
// v90 -> v91
238238
NewMigration("change length of some repository columns", changeSomeColumnsLengthOfRepo),
239+
// v91 -> v92
240+
NewMigration("add index on owner_id of repository and type, review_id of comment", addIndexOnRepositoryAndComment),
239241
}
240242

241243
// Migrate database to current version

models/migrations/v91.go

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2019 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import "github.com/go-xorm/xorm"
8+
9+
func addIndexOnRepositoryAndComment(x *xorm.Engine) error {
10+
type Repository struct {
11+
ID int64 `xorm:"pk autoincr"`
12+
OwnerID int64 `xorm:"index"`
13+
}
14+
15+
if err := x.Sync2(new(Repository)); err != nil {
16+
return err
17+
}
18+
19+
type Comment struct {
20+
ID int64 `xorm:"pk autoincr"`
21+
Type int `xorm:"index"`
22+
ReviewID int64 `xorm:"index"`
23+
}
24+
25+
return x.Sync2(new(Comment))
26+
}

models/models.go

+2
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ func NewTestEngine(x *xorm.Engine) (err error) {
262262
return fmt.Errorf("Connect to database: %v", err)
263263
}
264264

265+
x.ShowExecTime(true)
265266
x.SetMapper(core.GonicMapper{})
266267
x.SetLogger(NewXORMLogger(!setting.ProdMode))
267268
x.ShowSQL(!setting.ProdMode)
@@ -275,6 +276,7 @@ func SetEngine() (err error) {
275276
return fmt.Errorf("Failed to connect to database: %v", err)
276277
}
277278

279+
x.ShowExecTime(true)
278280
x.SetMapper(core.GonicMapper{})
279281
// WARNING: for serv command, MUST remove the output to os.stdout,
280282
// so use log file to instead print to stdout.

models/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func NewRepoContext() {
129129
// Repository represents a git repository.
130130
type Repository struct {
131131
ID int64 `xorm:"pk autoincr"`
132-
OwnerID int64 `xorm:"UNIQUE(s)"`
132+
OwnerID int64 `xorm:"UNIQUE(s) index"`
133133
OwnerName string `xorm:"-"`
134134
Owner *User `xorm:"-"`
135135
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`

modules/highlight/highlight.go

+79-35
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,93 @@ var (
2727
}
2828

2929
// Extensions that are same as highlight classes.
30+
// See hljs.listLanguages() for list of language names.
3031
highlightExts = map[string]struct{}{
31-
".arm": {},
32-
".as": {},
33-
".sh": {},
34-
".cs": {},
35-
".cpp": {},
36-
".c": {},
37-
".css": {},
38-
".cmake": {},
39-
".bat": {},
40-
".dart": {},
41-
".patch": {},
42-
".erl": {},
43-
".go": {},
44-
".html": {},
45-
".xml": {},
46-
".hs": {},
47-
".ini": {},
48-
".json": {},
49-
".java": {},
50-
".js": {},
51-
".less": {},
52-
".lua": {},
53-
".php": {},
54-
".py": {},
55-
".rb": {},
56-
".rs": {},
57-
".scss": {},
58-
".sql": {},
59-
".scala": {},
60-
".swift": {},
61-
".ts": {},
62-
".vb": {},
63-
".yml": {},
64-
".yaml": {},
32+
".applescript": {},
33+
".arm": {},
34+
".as": {},
35+
".bash": {},
36+
".bat": {},
37+
".c": {},
38+
".cmake": {},
39+
".cpp": {},
40+
".cs": {},
41+
".css": {},
42+
".dart": {},
43+
".diff": {},
44+
".django": {},
45+
".go": {},
46+
".gradle": {},
47+
".groovy": {},
48+
".haml": {},
49+
".handlebars": {},
50+
".html": {},
51+
".ini": {},
52+
".java": {},
53+
".json": {},
54+
".less": {},
55+
".lua": {},
56+
".php": {},
57+
".scala": {},
58+
".scss": {},
59+
".sql": {},
60+
".swift": {},
61+
".ts": {},
62+
".xml": {},
63+
".yaml": {},
6564
}
6665

6766
// Extensions that are not same as highlight classes.
6867
highlightMapping = map[string]string{
69-
".txt": "nohighlight",
68+
".ahk": "autohotkey",
69+
".crmsh": "crmsh",
70+
".dash": "shell",
71+
".erl": "erlang",
7072
".escript": "erlang",
7173
".ex": "elixir",
7274
".exs": "elixir",
75+
".f": "fortran",
76+
".f77": "fortran",
77+
".f90": "fortran",
78+
".f95": "fortran",
79+
".feature": "gherkin",
80+
".fish": "shell",
81+
".for": "fortran",
82+
".hbs": "handlebars",
83+
".hs": "haskell",
84+
".hx": "haxe",
85+
".js": "javascript",
86+
".jsx": "javascript",
87+
".ksh": "shell",
88+
".kt": "kotlin",
89+
".l": "ocaml",
90+
".ls": "livescript",
91+
".md": "markdown",
92+
".mjs": "javascript",
93+
".mli": "ocaml",
94+
".mll": "ocaml",
95+
".mly": "ocaml",
96+
".patch": "diff",
97+
".pl": "perl",
98+
".pm": "perl",
99+
".ps1": "powershell",
100+
".psd1": "powershell",
101+
".psm1": "powershell",
102+
".py": "python",
103+
".pyw": "python",
104+
".rb": "ruby",
105+
".rs": "rust",
106+
".scpt": "applescript",
107+
".scptd": "applescript",
108+
".sh": "bash",
109+
".tcsh": "shell",
110+
".ts": "typescript",
111+
".tsx": "typescript",
112+
".txt": "plaintext",
113+
".vb": "vbnet",
114+
".vbs": "vbscript",
115+
".yml": "yaml",
116+
".zsh": "shell",
73117
}
74118
)
75119

0 commit comments

Comments
 (0)