Skip to content

Commit e4b7cf7

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Use neutral language in comments and docs (go-gitea#20135) Fix remove file on initial comment (go-gitea#20127) Add doctor command to write commit-graphs (go-gitea#20007) Add sitemap support (go-gitea#18407) Use new config options (go-gitea#20125) Remove depricated queue indexer usage (go-gitea#20124) Disable status checks in template if none found (go-gitea#20088) Fix typos related to ErrTaskDoesNotExist error (go-gitea#20118)
2 parents 2dbef35 + 711cbcc commit e4b7cf7

File tree

27 files changed

+372
-26
lines changed

27 files changed

+372
-26
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,9 @@ PATH =
10971097
;; Number of items that are displayed in home feed
10981098
;FEED_PAGING_NUM = 20
10991099
;;
1100+
;; Number of items that are displayed in a single subsitemap
1101+
;SITEMAP_PAGING_NUM = 20
1102+
;;
11001103
;; Number of maximum commits displayed in commit graph.
11011104
;GRAPH_MAX_COMMIT_NUM = 100
11021105
;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
174174
- `MEMBERS_PAGING_NUM`: **20**: Number of members that are shown in organization members.
175175
- `FEED_MAX_COMMIT_NUM`: **5**: Number of maximum commits shown in one activity feed.
176176
- `FEED_PAGING_NUM`: **20**: Number of items that are displayed in home feed.
177+
- `SITEMAP_PAGING_NUM`: **20**: Number of items that are displayed in a single subsitemap.
177178
- `GRAPH_MAX_COMMIT_NUM`: **100**: Number of maximum commits shown in the commit graph.
178179
- `CODE_COMMENT_LINES`: **4**: Number of line of codes shown for a code comment.
179180
- `DEFAULT_THEME`: **auto**: \[auto, gitea, arc-green\]: Set the default theme for the Gitea install.

docs/content/doc/developers/oauth2-provider.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ To use the Authorization Code Grant as a third party application it is required
4141

4242
## Scopes
4343

44-
Currently Gitea does not support scopes (see [#4300](https://github.com/go-gitea/gitea/issues/4300)) and all third party applications will be granted access to all resources of the user and his/her organizations.
44+
Currently Gitea does not support scopes (see [#4300](https://github.com/go-gitea/gitea/issues/4300)) and all third party applications will be granted access to all resources of the user and their organizations.
4545

4646
## Example
4747

4848
**Note:** This example does not use PKCE.
4949

50-
1. Redirect to user to the authorization endpoint in order to get his/her consent for accessing the resources:
50+
1. Redirect to user to the authorization endpoint in order to get their consent for accessing the resources:
5151

5252
```curl
5353
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI& response_type=code&state=STATE

docs/content/doc/developers/oauth2-provider.zh-tw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Gitea 支援作為 OAuth2 提供者,能讓第三方程式能在使用者同意
4646
**備註:** 此範例未使用 PKCE。
4747

4848
1. 重新導向使用者到 authorization endpoint 以獲得他同意授權存取資源:
49-
<!-- 1. Redirect to user to the authorization endpoint in order to get his/her consent for accessing the resources: -->
49+
<!-- 1. Redirect to user to the authorization endpoint in order to get their consent for accessing the resources: -->
5050

5151
```curl
5252
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI& response_type=code&state=STATE

integrations/mssql.ini.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ PASSWD = {{TEST_MSSQL_PASSWORD}}
1010
SSL_MODE = disable
1111

1212
[indexer]
13-
ISSUE_INDEXER_PATH = integrations/gitea-integration-mssql/indexers/issues.bleve
14-
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-mssql/indexers/issues.queue
1513
REPO_INDEXER_ENABLED = true
1614
REPO_INDEXER_PATH = integrations/gitea-integration-mssql/indexers/repos.bleve
1715

16+
[queue.issue_indexer]
17+
PATH = integrations/gitea-integration-mssql/indexers/issues.bleve
18+
DATADIR = integrations/gitea-integration-mssql/indexers/issues.queue
19+
1820
[queue]
1921
TYPE = immediate
2022

integrations/mysql.ini.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ PASSWD = {{TEST_MYSQL_PASSWORD}}
1010
SSL_MODE = disable
1111

1212
[indexer]
13-
ISSUE_INDEXER_TYPE = elasticsearch
14-
ISSUE_INDEXER_CONN_STR = http://elastic:changeme@elasticsearch:9200
15-
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-mysql/indexers/issues.queue
1613
REPO_INDEXER_ENABLED = true
1714
REPO_INDEXER_PATH = integrations/gitea-integration-mysql/indexers/repos.bleve
1815

16+
[queue.issue_indexer]
17+
TYPE = elasticsearch
18+
CONN_STR = http://elastic:changeme@elasticsearch:9200
19+
DATADIR = integrations/gitea-integration-mysql/indexers/issues.queue
20+
1921
[queue]
2022
TYPE = immediate
2123

integrations/mysql8.ini.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ PASSWD = {{TEST_MYSQL8_PASSWORD}}
1010
SSL_MODE = disable
1111

1212
[indexer]
13-
ISSUE_INDEXER_PATH = integrations/gitea-integration-mysql8/indexers/issues.bleve
14-
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-mysql8/indexers/issues.queue
1513
REPO_INDEXER_ENABLED = true
1614
REPO_INDEXER_PATH = integrations/gitea-integration-mysql8/indexers/repos.bleve
1715

16+
[queue.issue_indexer]
17+
PATH = integrations/gitea-integration-mysql8/indexers/issues.bleve
18+
DATADIR = integrations/gitea-integration-mysql8/indexers/issues.queue
19+
1820
[queue]
1921
TYPE = immediate
2022

integrations/pgsql.ini.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ SCHEMA = {{TEST_PGSQL_SCHEMA}}
1111
SSL_MODE = disable
1212

1313
[indexer]
14-
ISSUE_INDEXER_PATH = integrations/gitea-integration-pgsql/indexers/issues.bleve
15-
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-pgsql/indexers/issues.queue
1614
REPO_INDEXER_ENABLED = true
1715
REPO_INDEXER_PATH = integrations/gitea-integration-pgsql/indexers/repos.bleve
1816

17+
[queue.issue_indexer]
18+
PATH = integrations/gitea-integration-pgsql/indexers/issues.bleve
19+
DATADIR = integrations/gitea-integration-pgsql/indexers/issues.queue
20+
1921
[queue]
2022
TYPE = immediate
2123

integrations/sqlite.ini.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ DB_TYPE = sqlite3
66
PATH = integrations/gitea-integration-sqlite/gitea.db
77

88
[indexer]
9-
ISSUE_INDEXER_PATH = integrations/gitea-integration-sqlite/indexers/issues.bleve
10-
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-sqlite/indexers/issues.queue
119
REPO_INDEXER_ENABLED = true
1210
REPO_INDEXER_PATH = integrations/gitea-integration-sqlite/indexers/repos.bleve
1311

12+
[queue.issue_indexer]
13+
PATH = integrations/gitea-integration-sqlite/indexers/issues.bleve
14+
DATADIR = integrations/gitea-integration-sqlite/indexers/issues.queue
15+
1416
[queue]
1517
TYPE = immediate
1618

models/migrations/v154.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func addTimeStamps(x *xorm.Engine) error {
3030
return err
3131
}
3232

33-
// Follow represents relations of user and his/her followers.
33+
// Follow represents relations of user and their followers.
3434
type Follow struct {
3535
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
3636
}

models/org.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func removeOrgUser(ctx context.Context, orgID, userID int64) error {
149149
}
150150
}
151151

152-
// Delete member in his/her teams.
152+
// Delete member in their teams.
153153
teams, err := organization.GetUserOrgTeams(ctx, org.ID, userID)
154154
if err != nil {
155155
return err

models/task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ type ErrTaskDoesNotExist struct {
156156
Type structs.TaskType
157157
}
158158

159-
// IsErrTaskDoesNotExist checks if an error is a ErrTaskIsNotExist.
159+
// IsErrTaskDoesNotExist checks if an error is a ErrTaskDoesNotExist.
160160
func IsErrTaskDoesNotExist(err error) bool {
161161
_, ok := err.(ErrTaskDoesNotExist)
162162
return ok
163163
}
164164

165165
func (err ErrTaskDoesNotExist) Error() string {
166-
return fmt.Sprintf("task is not exist [id: %d, repo_id: %d, type: %d]",
166+
return fmt.Sprintf("task does not exist [id: %d, repo_id: %d, type: %d]",
167167
err.ID, err.RepoID, err.Type)
168168
}
169169

models/user/follow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"code.gitea.io/gitea/modules/timeutil"
1010
)
1111

12-
// Follow represents relations of user and his/her followers.
12+
// Follow represents relations of user and their followers.
1313
type Follow struct {
1414
ID int64 `xorm:"pk autoincr"`
1515
UserID int64 `xorm:"UNIQUE(follow)"`

models/user/user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ type User struct {
8686
PasswdHashAlgo string `xorm:"NOT NULL DEFAULT 'argon2'"`
8787

8888
// MustChangePassword is an attribute that determines if a user
89-
// is to change his/her password after registration.
89+
// is to change their password after registration.
9090
MustChangePassword bool `xorm:"NOT NULL DEFAULT false"`
9191

9292
LoginType auth.Type
@@ -537,7 +537,7 @@ func GetUserSalt() (string, error) {
537537
return hex.EncodeToString(rBytes), nil
538538
}
539539

540-
// NewGhostUser creates and returns a fake user for someone has deleted his/her account.
540+
// NewGhostUser creates and returns a fake user for someone has deleted their account.
541541
func NewGhostUser() *User {
542542
return &User{
543543
ID: -1,

modules/doctor/mergebase.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func iteratePRs(ctx context.Context, repo *repo_model.Repository, each func(*rep
3030
}
3131

3232
func checkPRMergeBase(ctx context.Context, logger log.Logger, autofix bool) error {
33+
if err := git.InitOnceWithSync(ctx); err != nil {
34+
return err
35+
}
3336
numRepos := 0
3437
numPRs := 0
3538
numPRsUpdated := 0

modules/doctor/misc.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,75 @@ func checkDaemonExport(ctx context.Context, logger log.Logger, autofix bool) err
189189
return nil
190190
}
191191

192+
func checkCommitGraph(ctx context.Context, logger log.Logger, autofix bool) error {
193+
if err := git.InitOnceWithSync(ctx); err != nil {
194+
return err
195+
}
196+
197+
numRepos := 0
198+
numNeedUpdate := 0
199+
numWritten := 0
200+
if err := iterateRepositories(ctx, func(repo *repo_model.Repository) error {
201+
numRepos++
202+
203+
commitGraphExists := func() (bool, error) {
204+
// Check commit-graph exists
205+
commitGraphFile := path.Join(repo.RepoPath(), `objects/info/commit-graph`)
206+
isExist, err := util.IsExist(commitGraphFile)
207+
if err != nil {
208+
logger.Error("Unable to check if %s exists. Error: %v", commitGraphFile, err)
209+
return false, err
210+
}
211+
212+
if !isExist {
213+
commitGraphsDir := path.Join(repo.RepoPath(), `objects/info/commit-graphs`)
214+
isExist, err = util.IsExist(commitGraphsDir)
215+
if err != nil {
216+
logger.Error("Unable to check if %s exists. Error: %v", commitGraphsDir, err)
217+
return false, err
218+
}
219+
}
220+
return isExist, nil
221+
}
222+
223+
isExist, err := commitGraphExists()
224+
if err != nil {
225+
return err
226+
}
227+
if !isExist {
228+
numNeedUpdate++
229+
if autofix {
230+
if err := git.WriteCommitGraph(ctx, repo.RepoPath()); err != nil {
231+
logger.Error("Unable to write commit-graph in %s. Error: %v", repo.FullName(), err)
232+
return err
233+
}
234+
isExist, err := commitGraphExists()
235+
if err != nil {
236+
return err
237+
}
238+
if isExist {
239+
numWritten++
240+
logger.Info("Commit-graph written: %s", repo.FullName())
241+
} else {
242+
logger.Warn("No commit-graph written: %s", repo.FullName())
243+
}
244+
}
245+
}
246+
return nil
247+
}); err != nil {
248+
logger.Critical("Unable to checkCommitGraph: %v", err)
249+
return err
250+
}
251+
252+
if autofix {
253+
logger.Info("Wrote commit-graph files for %d of %d repositories.", numWritten, numRepos)
254+
} else {
255+
logger.Info("Checked %d repositories, %d without commit-graphs.", numRepos, numNeedUpdate)
256+
}
257+
258+
return nil
259+
}
260+
192261
func init() {
193262
Register(&Check{
194263
Title: "Check if SCRIPT_TYPE is available",
@@ -225,4 +294,11 @@ func init() {
225294
Run: checkDaemonExport,
226295
Priority: 8,
227296
})
297+
Register(&Check{
298+
Title: "Check commit-graphs",
299+
Name: "check-commit-graphs",
300+
IsDefault: false,
301+
Run: checkCommitGraph,
302+
Priority: 9,
303+
})
228304
}

modules/setting/setting.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ var (
207207
// UI settings
208208
UI = struct {
209209
ExplorePagingNum int
210+
SitemapPagingNum int
210211
IssuePagingNum int
211212
RepoSearchPagingNum int
212213
MembersPagingNum int
@@ -260,6 +261,7 @@ var (
260261
} `ini:"ui.meta"`
261262
}{
262263
ExplorePagingNum: 20,
264+
SitemapPagingNum: 20,
263265
IssuePagingNum: 10,
264266
RepoSearchPagingNum: 10,
265267
MembersPagingNum: 20,

modules/sitemap/sitemap.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright 2022 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 sitemap
6+
7+
import (
8+
"bytes"
9+
"encoding/xml"
10+
"fmt"
11+
"io"
12+
"time"
13+
)
14+
15+
// sitemapFileLimit contains the maximum size of a sitemap file
16+
const sitemapFileLimit = 50 * 1024 * 1024
17+
18+
// Url represents a single sitemap entry
19+
type URL struct {
20+
URL string `xml:"loc"`
21+
LastMod *time.Time `xml:"lastmod,omitempty"`
22+
}
23+
24+
// SitemapUrl represents a sitemap
25+
type Sitemap struct {
26+
XMLName xml.Name
27+
Namespace string `xml:"xmlns,attr"`
28+
29+
URLs []URL `xml:"url"`
30+
}
31+
32+
// NewSitemap creates a sitemap
33+
func NewSitemap() *Sitemap {
34+
return &Sitemap{
35+
XMLName: xml.Name{Local: "urlset"},
36+
Namespace: "http://www.sitemaps.org/schemas/sitemap/0.9",
37+
}
38+
}
39+
40+
// NewSitemap creates a sitemap index.
41+
func NewSitemapIndex() *Sitemap {
42+
return &Sitemap{
43+
XMLName: xml.Name{Local: "sitemapindex"},
44+
Namespace: "http://www.sitemaps.org/schemas/sitemap/0.9",
45+
}
46+
}
47+
48+
// Add adds a URL to the sitemap
49+
func (s *Sitemap) Add(u URL) {
50+
s.URLs = append(s.URLs, u)
51+
}
52+
53+
// Write writes the sitemap to a response
54+
func (s *Sitemap) WriteTo(w io.Writer) (int64, error) {
55+
if len(s.URLs) > 50000 {
56+
return 0, fmt.Errorf("The sitemap contains too many URLs: %d", len(s.URLs))
57+
}
58+
buf := bytes.NewBufferString(xml.Header)
59+
if err := xml.NewEncoder(buf).Encode(s); err != nil {
60+
return 0, err
61+
}
62+
if err := buf.WriteByte('\n'); err != nil {
63+
return 0, err
64+
}
65+
if buf.Len() > sitemapFileLimit {
66+
return 0, fmt.Errorf("The sitemap is too big: %d", buf.Len())
67+
}
68+
return buf.WriteTo(w)
69+
}

0 commit comments

Comments
 (0)