Skip to content

Commit deef959

Browse files
authored
Merge branch 'master' into slight-performance-improvement-for-last-commit-cache
2 parents d51a521 + 8202dd1 commit deef959

Some content is hidden

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

49 files changed

+669
-251
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,9 @@ release-windows: | $(DIST_DIRS)
613613
$(GO) install src.techknowlogick.com/xgo@latest; \
614614
fi
615615
CGO_CFLAGS="$(CGO_CFLAGS)" xgo -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
616+
ifeq (,$(findstring gogit,$(TAGS)))
617+
CGO_CFLAGS="$(CGO_CFLAGS)" xgo -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit .
618+
endif
616619
ifeq ($(CI),drone)
617620
cp /build/* $(DIST)/binaries
618621
endif
@@ -733,8 +736,8 @@ generate-gitignore:
733736
GO111MODULE=on $(GO) run build/generate-gitignores.go
734737

735738
.PHONY: generate-images
736-
generate-images:
737-
npm install --no-save --no-package-lock fabric imagemin-zopfli
739+
generate-images: | node_modules
740+
npm install --no-save --no-package-lock fabric@4 imagemin-zopfli@7
738741
node build/generate-images.js $(TAGS)
739742

740743
.PHONY: generate-manpage

build/generate-images.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import imageminZopfli from 'imagemin-zopfli';
22
import {optimize, extendDefaultPlugins} from 'svgo';
33
import {fabric} from 'fabric';
4-
import {readFile, writeFile} from 'fs/promises';
4+
import fs from 'fs';
55
import {resolve, dirname} from 'path';
66
import {fileURLToPath} from 'url';
77

8+
const {readFile, writeFile} = fs.promises;
89
const __dirname = dirname(fileURLToPath(import.meta.url));
910
const logoFile = resolve(__dirname, '../assets/logo.svg');
1011

build/generate-svg.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import fastGlob from 'fast-glob';
22
import {optimize, extendDefaultPlugins} from 'svgo';
33
import {resolve, parse, dirname} from 'path';
4-
import {readFile, writeFile, mkdir} from 'fs/promises';
4+
import fs from 'fs';
55
import {fileURLToPath} from 'url';
66

7+
const {readFile, writeFile, mkdir} = fs.promises;
78
const __dirname = dirname(fileURLToPath(import.meta.url));
89
const glob = (pattern) => fastGlob.sync(pattern, {cwd: resolve(__dirname), absolute: true});
910
const outputDir = resolve(__dirname, '../public/img/svg');

custom/conf/app.example.ini

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PROJECT_BOARD_BASIC_KANBAN_TYPE = To Do, In Progress, Done
1919
PROJECT_BOARD_BUG_TRIAGE_TYPE = Needs Triage, High Priority, Low Priority, Closed
2020

2121
[repository]
22-
; Root path for storing all repository data. It must be an absolute path. By default it is stored in a sub-directory of `APP_DATA_PATH`.
22+
; Root path for storing all repository data. It must be an absolute path. By default, it is stored in a sub-directory of `APP_DATA_PATH`.
2323
ROOT =
2424
; The script type this server supports. Usually this is `bash`, but some users report that only `sh` is available.
2525
SCRIPT_TYPE = bash
@@ -48,7 +48,7 @@ PREFERRED_LICENSES = Apache License 2.0,MIT License
4848
; Disable the ability to interact with repositories using the HTTP protocol
4949
DISABLE_HTTP_GIT = false
5050
; Value for Access-Control-Allow-Origin header, default is not to present
51-
; WARNING: This maybe harmful to you website if you do not give it a right value.
51+
; WARNING: This may be harmful to your website if you do not give it a right value.
5252
ACCESS_CONTROL_ALLOW_ORIGIN =
5353
; Force ssh:// clone url instead of scp-style uri when default SSH port is used
5454
USE_COMPAT_SSH_URI = false
@@ -70,6 +70,8 @@ PREFIX_ARCHIVE_FILES = true
7070
DISABLE_MIRRORS = false
7171
; Disable migrating feature.
7272
DISABLE_MIGRATIONS = false
73+
; Disable stars feature.
74+
DISABLE_STARS = false
7375
; The default branch name of new repositories
7476
DEFAULT_BRANCH = master
7577
; Allow adoption of unadopted repositories
@@ -134,7 +136,7 @@ ALLOWED_TYPES =
134136
SIGNING_KEY = default
135137
; If a SIGNING_KEY ID is provided and is not set to default, use the provided Name and Email address as the signer.
136138
; These should match a publicized name and email address for the key. (When SIGNING_KEY is default these are set to
137-
; the results of git config --get user.name and git config --get user.email respectively and can only be overrided
139+
; the results of git config --get user.name and git config --get user.email respectively and can only be overridden
138140
; by setting the SIGNING_KEY ID to the correct ID.)
139141
SIGNING_NAME =
140142
SIGNING_EMAIL =
@@ -447,7 +449,7 @@ LOG_SQL = true
447449
DB_RETRIES = 10
448450
; Backoff time per DB retry (time.Duration)
449451
DB_RETRY_BACKOFF = 3s
450-
; Max idle database connections on connnection pool, default is 2
452+
; Max idle database connections on connection pool, default is 2
451453
MAX_IDLE_CONNS = 2
452454
; Database connection max life time, default is 0 or 3s mysql (See #6804 & #7071 for reasoning)
453455
CONN_MAX_LIFETIME = 3s
@@ -466,7 +468,7 @@ ISSUE_INDEXER_PATH = indexers/issues.bleve
466468
; Issue indexer queue, currently support: channel, levelqueue or redis, default is levelqueue
467469
ISSUE_INDEXER_QUEUE_TYPE = levelqueue
468470
; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
469-
; This can be overriden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
471+
; This can be overridden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
470472
; default is indexers/issues.queue
471473
ISSUE_INDEXER_QUEUE_DIR = indexers/issues.queue
472474
; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
@@ -514,9 +516,9 @@ BATCH_LENGTH = 20
514516
; When `TYPE` is `persistable-channel`, this provides a directory for the underlying leveldb
515517
; or additional options of the form `leveldb://path/to/db?option=value&....`, and will override `DATADIR`.
516518
CONN_STR = "addrs=127.0.0.1:6379 db=0"
517-
; Provides the suffix of the default redis/disk queue name - specific queues can be overriden within in their [queue.name] sections.
519+
; Provides the suffix of the default redis/disk queue name - specific queues can be overridden within in their [queue.name] sections.
518520
QUEUE_NAME = "_queue"
519-
; Provides the suffix of the default redis/disk unique queue set name - specific queues can be overriden within in their [queue.name] sections.
521+
; Provides the suffix of the default redis/disk unique queue set name - specific queues can be overridden within in their [queue.name] sections.
520522
SET_NAME = "_unique"
521523
; If the queue cannot be created at startup - level queues may need a timeout at startup - wrap the queue:
522524
WRAP_IF_NECESSARY = true
@@ -617,6 +619,30 @@ WHITELISTED_URIS =
617619
; Example value: loadaverage.org/badguy stackexchange.com/.*spammer
618620
BLACKLISTED_URIS =
619621

622+
[oauth2_client]
623+
; Whether a new auto registered oauth2 user needs to confirm their email.
624+
; Do not include to use the REGISTER_EMAIL_CONFIRM setting from the `[service]` section.
625+
REGISTER_EMAIL_CONFIRM =
626+
; Scopes for the openid connect oauth2 provider (separated by space, the openid scope is implicitly added).
627+
; Typical values are profile and email.
628+
; For more information about the possible values see https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims
629+
OPENID_CONNECT_SCOPES =
630+
; Automatically create user accounts for new oauth2 users.
631+
ENABLE_AUTO_REGISTRATION = false
632+
; The source of the username for new oauth2 accounts:
633+
; userid = use the userid / sub attribute
634+
; nickname = use the nickname attribute
635+
; email = use the username part of the email attribute
636+
USERNAME = nickname
637+
; Update avatar if available from oauth2 provider.
638+
; Update will be performed on each login.
639+
UPDATE_AVATAR = false
640+
; How to handle if an account / email already exists:
641+
; disabled = show an error
642+
; login = show an account linking login
643+
; auto = link directly with the account
644+
ACCOUNT_LINKING = disabled
645+
620646
[service]
621647
; Time limit to confirm account/email registration
622648
ACTIVE_CODE_LIVE_MINUTES = 180
@@ -822,7 +848,7 @@ REPOSITORY_AVATAR_FALLBACK_IMAGE = /img/repo_default.png
822848
; This is to limit the amount of RAM used when resizing the image.
823849
AVATAR_MAX_WIDTH = 4096
824850
AVATAR_MAX_HEIGHT = 3072
825-
; Maximum alloved file size for uploaded avatars.
851+
; Maximum allowed file size for uploaded avatars.
826852
; This is to limit the amount of RAM used when resizing the image.
827853
AVATAR_MAX_FILE_SIZE = 1048576
828854
; Chinese users can choose "duoshuo"

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
7575
- `PREFIX_ARCHIVE_FILES`: **true**: Prefix archive files by placing them in a directory named after the repository.
7676
- `DISABLE_MIRRORS`: **false**: Disable the creation of **new** mirrors. Pre-existing mirrors remain valid.
7777
- `DISABLE_MIGRATIONS`: **false**: Disable migrating feature.
78+
- `DISABLE_STARS`: **false**: Disable stars feature.
7879
- `DEFAULT_BRANCH`: **master**: Default branch name of all repositories.
7980
- `ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to adopt unadopted repositories
8081
- `ALLOW_DELETION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to delete unadopted repositories
@@ -429,6 +430,21 @@ relation to port exhaustion.
429430
- `BLACKLISTED_URIS`: **\<empty\>**: If non-empty, list of POSIX regex patterns matching
430431
OpenID URI's to block.
431432

433+
## OAuth2 Client (`oauth2_client`)
434+
435+
- `REGISTER_EMAIL_CONFIRM`: *[service]* **REGISTER\_EMAIL\_CONFIRM**: Set this to enable or disable email confirmation of OAuth2 auto-registration. (Overwrites the REGISTER\_EMAIL\_CONFIRM setting of the `[service]` section)
436+
- `OPENID_CONNECT_SCOPES`: **\<empty\>**: List of additional openid connect scopes. (`openid` is implicitly added)
437+
- `ENABLE_AUTO_REGISTRATION`: **false**: Automatically create user accounts for new oauth2 users.
438+
- `USERNAME`: **nickname**: The source of the username for new oauth2 accounts:
439+
- userid - use the userid / sub attribute
440+
- nickname - use the nickname attribute
441+
- email - use the username part of the email attribute
442+
- `UPDATE_AVATAR`: **false**: Update avatar if available from oauth2 provider. Update will be performed on each login.
443+
- `ACCOUNT_LINKING`: **disabled**: How to handle if an account / email already exists:
444+
- disabled - show an error
445+
- login - show an account linking login
446+
- auto - automatically link with the account (Please be aware that this will grant access to an existing account just because the same username or email is provided. You must make sure that this does not cause issues with your authentication providers.)
447+
432448
## Service (`service`)
433449

434450
- `ACTIVE_CODE_LIVE_MINUTES`: **180**: Time limit (min) to confirm account/email registration.

docs/content/doc/advanced/signing.en-us.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ when creating a repository. The possible values are:
109109
- `always`: Always sign
110110

111111
Options other than `never` and `always` can be combined as a comma
112-
separated list.
112+
separated list. The commit will be signed if all selected options are true.
113113

114114
### `WIKI`
115115

@@ -123,7 +123,7 @@ The possible values are:
123123
- `always`: Always sign
124124

125125
Options other than `never` and `always` can be combined as a comma
126-
separated list.
126+
separated list. The commit will be signed if all selected options are true.
127127

128128
### `CRUD_ACTIONS`
129129

@@ -137,7 +137,7 @@ editor or API CRUD actions. The possible values are:
137137
- `always`: Always sign
138138

139139
Options other than `never` and `always` can be combined as a comma
140-
separated list.
140+
separated list. The change will be signed if all selected options are true.
141141

142142
### `MERGES`
143143

@@ -154,7 +154,7 @@ The possible options are:
154154
- `always`: Always sign
155155

156156
Options other than `never` and `always` can be combined as a comma
157-
separated list.
157+
separated list. The merge will be signed if all selected options are true.
158158

159159
## Obtaining the Public Key of the Signing Key
160160

models/avatar.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ func HashedAvatarLink(email string) string {
9696
// we don't care about any DB problem just return the lowerEmail
9797
return lowerEmail, nil
9898
}
99+
has, err := sess.Where("email = ? AND hash = ?", emailHash.Email, emailHash.Hash).Get(new(EmailHash))
100+
if has || err != nil {
101+
// Seriously we don't care about any DB problems just return the lowerEmail - we expect the transaction to fail most of the time
102+
return lowerEmail, nil
103+
}
99104
_, _ = sess.Insert(emailHash)
100105
if err := sess.Commit(); err != nil {
101106
// Seriously we don't care about any DB problems just return the lowerEmail - we expect the transaction to fail most of the time

models/issue_list.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func (issues IssueList) loadRepositories(e Engine) ([]*Repository, error) {
5353

5454
for _, issue := range issues {
5555
issue.Repo = repoMaps[issue.RepoID]
56+
if issue.PullRequest != nil {
57+
issue.PullRequest.BaseRepo = issue.Repo
58+
}
5659
}
5760
return valuesRepository(repoMaps), nil
5861
}
@@ -516,6 +519,11 @@ func (issues IssueList) LoadDiscussComments() error {
516519
return issues.loadComments(x, builder.Eq{"comment.type": CommentTypeComment})
517520
}
518521

522+
// LoadPullRequests loads pull requests
523+
func (issues IssueList) LoadPullRequests() error {
524+
return issues.loadPullRequests(x)
525+
}
526+
519527
// GetApprovalCounts returns a map of issue ID to slice of approval counts
520528
// FIXME: only returns official counts due to double counting of non-official approvals
521529
func (issues IssueList) GetApprovalCounts() (map[int64][]*ReviewCount, error) {

models/migrations/migrations.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,13 @@ var migrations = []Migration{
302302
NewMigration("Remove invalid labels from comments", removeInvalidLabels),
303303
// v177 -> v178
304304
NewMigration("Delete orphaned IssueLabels", deleteOrphanedIssueLabels),
305+
306+
// Gitea 1.14.0 ends at v178
307+
305308
// v178 -> v179
306309
NewMigration("Add LFS columns to Mirror", addLFSMirrorColumns),
310+
// v179 -> v180
311+
NewMigration("Convert avatar url to text", convertAvatarURLToText),
307312
}
308313

309314
// GetCurrentDBVersion returns the current db version

models/migrations/v172.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212

1313
func addSessionTable(x *xorm.Engine) error {
1414
type Session struct {
15-
Key string `xorm:"pk CHAR(16)"`
16-
Data []byte `xorm:"BLOB"`
17-
CreatedUnix timeutil.TimeStamp
15+
Key string `xorm:"pk CHAR(16)"`
16+
Data []byte `xorm:"BLOB"`
17+
Expiry timeutil.TimeStamp
1818
}
1919
return x.Sync2(new(Session))
2020
}

models/migrations/v179.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2021 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 (
8+
"xorm.io/xorm"
9+
"xorm.io/xorm/schemas"
10+
)
11+
12+
func convertAvatarURLToText(x *xorm.Engine) error {
13+
dbType := x.Dialect().URI().DBType
14+
if dbType == schemas.SQLITE { // For SQLITE, varchar or char will always be represented as TEXT
15+
return nil
16+
}
17+
18+
// Some oauth2 providers may give very long avatar urls (i.e. Google)
19+
return modifyColumn(x, "external_login_user", &schemas.Column{
20+
Name: "avatar_url",
21+
SQLType: schemas.SQLType{
22+
Name: schemas.Text,
23+
},
24+
Nullable: true,
25+
})
26+
}

models/repo_list.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ type SearchRepoOptions struct {
143143
OrderBy SearchOrderBy
144144
Private bool // Include private repositories in results
145145
StarredByID int64
146+
WatchedByID int64
146147
AllPublic bool // Include also all public repositories of users and public organisations
147148
AllLimited bool // Include also all public repositories of limited organisations
148149
// None -> include public and private
@@ -241,6 +242,11 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
241242
cond = cond.And(builder.In("id", builder.Select("repo_id").From("star").Where(builder.Eq{"uid": opts.StarredByID})))
242243
}
243244

245+
// Restrict to watched repositories
246+
if opts.WatchedByID > 0 {
247+
cond = cond.And(builder.In("id", builder.Select("repo_id").From("watch").Where(builder.Eq{"user_id": opts.WatchedByID})))
248+
}
249+
244250
// Restrict repositories to those the OwnerID owns or contributes to as per opts.Collaborate
245251
if opts.OwnerID > 0 {
246252
accessCond := builder.NewCond()

models/review.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,11 @@ func DismissReview(review *Review, isDismiss bool) (err error) {
566566

567567
review.Dismissed = isDismiss
568568

569-
_, err = x.Cols("dismissed").Update(review)
569+
if review.ID == 0 {
570+
return ErrReviewNotExist{}
571+
}
572+
573+
_, err = x.ID(review.ID).Cols("dismissed").Update(review)
570574

571575
return
572576
}

0 commit comments

Comments
 (0)