Skip to content

Commit c2842fb

Browse files
committed
Merge remote-tracking branch 'origin/main' into prevent-npe-when-migrating-if-reviewer-nil
2 parents 27918e3 + d8236f1 commit c2842fb

File tree

176 files changed

+3083
-6401
lines changed

Some content is hidden

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

176 files changed

+3083
-6401
lines changed

.drone.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ steps:
331331
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
332332
user: gitea
333333
commands:
334-
- timeout -s ABRT 40m make test-mysql8-migration test-mysql8
334+
- timeout -s ABRT 50m make test-mysql8-migration test-mysql8
335335
environment:
336336
GOPROXY: https://goproxy.io
337337
TAGS: bindata
@@ -469,7 +469,7 @@ steps:
469469
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
470470
user: gitea
471471
commands:
472-
- timeout -s ABRT 40m make test-sqlite-migration test-sqlite
472+
- timeout -s ABRT 50m make test-sqlite-migration test-sqlite
473473
environment:
474474
GOPROXY: https://goproxy.io
475475
TAGS: bindata gogit sqlite sqlite_unlock_notify
@@ -485,7 +485,7 @@ steps:
485485
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
486486
user: gitea
487487
commands:
488-
- timeout -s ABRT 40m make test-pgsql-migration test-pgsql
488+
- timeout -s ABRT 50m make test-pgsql-migration test-pgsql
489489
environment:
490490
GOPROXY: https://goproxy.io
491491
TAGS: bindata gogit

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ contact_links:
44
url: https://tinyurl.com/security-gitea
55
about: For security concerns, please send a mail to [email protected] instead of opening a public issue.
66
- name: Discord Server
7-
url: https://discord.gg/gitea
7+
url: https://discord.gg/Gitea
88
about: Please ask questions and discuss configuration or deployment problems here.
99
- name: Discourse Forum
1010
url: https://discourse.gitea.io

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ Leon Hofmeister <[email protected]> (@delvh)
4747
Gusted <[email protected]) (@Gusted)
4848
singuliere <[email protected]> (@singuliere)
4949
silentcode <[email protected]> (@silentcodeg)
50+
Wim <[email protected]> (@42wim)

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,27 +616,27 @@ release-windows: | $(DIST_DIRS)
616616
ifeq (,$(findstring gogit,$(TAGS)))
617617
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -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 .
618618
endif
619-
ifeq ($(CI),drone)
619+
ifeq ($(CI),true)
620620
cp /build/* $(DIST)/binaries
621621
endif
622622

623623
.PHONY: release-linux
624624
release-linux: | $(DIST_DIRS)
625625
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out gitea-$(VERSION) .
626-
ifeq ($(CI),drone)
626+
ifeq ($(CI),true)
627627
cp /build/* $(DIST)/binaries
628628
endif
629629

630630
.PHONY: release-darwin
631631
release-darwin: | $(DIST_DIRS)
632632
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin-10.12/amd64,darwin-10.12/arm64' -out gitea-$(VERSION) .
633-
ifeq ($(CI),drone)
633+
ifeq ($(CI),true)
634634
cp /build/* $(DIST)/binaries
635635
endif
636636

637637
.PHONY: release-copy
638638
release-copy: | $(DIST_DIRS)
639-
cd $(DIST); for file in `find /build -type f -name "*"`; do cp $${file} ./release/; done;
639+
cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
640640

641641
.PHONY: release-check
642642
release-check: | $(DIST_DIRS)
@@ -703,7 +703,6 @@ fomantic:
703703
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
704704
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
705705
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
706-
cp -f web_src/js/vendor/dropdown.js $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/definitions/modules
707706
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
708707
rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*
709708

@@ -762,7 +761,7 @@ generate-gitignore:
762761

763762
.PHONY: generate-images
764763
generate-images: | node_modules
765-
npm install --no-save --no-package-lock fabric@4 imagemin-zopfli@7
764+
npm install --no-save --no-package-lock fabric@5 imagemin-zopfli@7
766765
node build/generate-images.js $(TAGS)
767766

768767
.PHONY: generate-manpage

build/generate-images.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1+
#!/usr/bin/env node
12
import imageminZopfli from 'imagemin-zopfli';
23
import {optimize} from 'svgo';
34
import {fabric} from 'fabric';
4-
import fs from 'fs';
5-
import {resolve, dirname} from 'path';
6-
import {fileURLToPath} from 'url';
7-
8-
const {readFile, writeFile} = fs.promises;
9-
const __dirname = dirname(fileURLToPath(import.meta.url));
10-
const logoFile = resolve(__dirname, '../assets/logo.svg');
11-
const faviconFile = resolve(__dirname, '../assets/favicon.svg');
5+
import {readFile, writeFile} from 'fs/promises';
126

137
function exit(err) {
148
if (err) console.error(err);
@@ -23,8 +17,10 @@ function loadSvg(svg) {
2317
});
2418
}
2519

26-
async function generate(svg, outputFile, {size, bg}) {
27-
if (outputFile.endsWith('.svg')) {
20+
async function generate(svg, path, {size, bg}) {
21+
const outputFile = new URL(path, import.meta.url);
22+
23+
if (String(outputFile).endsWith('.svg')) {
2824
const {data} = optimize(svg, {
2925
plugins: [
3026
'preset-default',
@@ -69,19 +65,18 @@ async function generate(svg, outputFile, {size, bg}) {
6965

7066
async function main() {
7167
const gitea = process.argv.slice(2).includes('gitea');
72-
const logoSvg = await readFile(logoFile, 'utf8');
73-
const faviconSvg = await readFile(faviconFile, 'utf8');
68+
const logoSvg = await readFile(new URL('../assets/logo.svg', import.meta.url), 'utf8');
69+
const faviconSvg = await readFile(new URL('../assets/favicon.svg', import.meta.url), 'utf8');
7470

7571
await Promise.all([
76-
generate(logoSvg, resolve(__dirname, '../public/img/logo.svg'), {size: 32}),
77-
generate(logoSvg, resolve(__dirname, '../public/img/logo.png'), {size: 512}),
78-
generate(faviconSvg, resolve(__dirname, '../public/img/favicon.svg'), {size: 32}),
79-
generate(faviconSvg, resolve(__dirname, '../public/img/favicon.png'), {size: 180}),
80-
generate(logoSvg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200}),
81-
generate(logoSvg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true}),
82-
gitea && generate(logoSvg, resolve(__dirname, '../public/img/gitea.svg'), {size: 32}),
72+
generate(logoSvg, '../public/img/logo.svg', {size: 32}),
73+
generate(logoSvg, '../public/img/logo.png', {size: 512}),
74+
generate(faviconSvg, '../public/img/favicon.svg', {size: 32}),
75+
generate(faviconSvg, '../public/img/favicon.png', {size: 180}),
76+
generate(logoSvg, '../public/img/avatar_default.png', {size: 200}),
77+
generate(logoSvg, '../public/img/apple-touch-icon.png', {size: 180, bg: true}),
78+
gitea && generate(logoSvg, '../public/img/gitea.svg', {size: 32}),
8379
]);
8480
}
8581

8682
main().then(exit).catch(exit);
87-

build/generate-svg.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
#!/usr/bin/env node
12
import fastGlob from 'fast-glob';
23
import {optimize} from 'svgo';
3-
import {resolve, parse, dirname} from 'path';
4-
import fs from 'fs';
4+
import {parse} from 'path';
5+
import {readFile, writeFile, mkdir} from 'fs/promises';
56
import {fileURLToPath} from 'url';
67

7-
const {readFile, writeFile, mkdir} = fs.promises;
8-
const __dirname = dirname(fileURLToPath(import.meta.url));
9-
const glob = (pattern) => fastGlob.sync(pattern, {cwd: resolve(__dirname), absolute: true});
10-
const outputDir = resolve(__dirname, '../public/img/svg');
8+
const glob = (pattern) => fastGlob.sync(pattern, {
9+
cwd: fileURLToPath(new URL('..', import.meta.url)),
10+
absolute: true,
11+
});
1112

1213
function exit(err) {
1314
if (err) console.error(err);
@@ -16,7 +17,6 @@ function exit(err) {
1617

1718
async function processFile(file, {prefix, fullName} = {}) {
1819
let name;
19-
2020
if (fullName) {
2121
name = fullName;
2222
} else {
@@ -35,7 +35,8 @@ async function processFile(file, {prefix, fullName} = {}) {
3535
{name: 'addAttributesToSVGElement', params: {attributes: [{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'}]}},
3636
],
3737
});
38-
await writeFile(resolve(outputDir, `${name}.svg`), data);
38+
39+
await writeFile(fileURLToPath(new URL(`../public/img/svg/${name}.svg`, import.meta.url)), data);
3940
}
4041

4142
function processFiles(pattern, opts) {
@@ -44,15 +45,14 @@ function processFiles(pattern, opts) {
4445

4546
async function main() {
4647
try {
47-
await mkdir(outputDir);
48+
await mkdir(fileURLToPath(new URL('../public/img/svg', import.meta.url)), {recursive: true});
4849
} catch {}
4950

5051
await Promise.all([
51-
...processFiles('../node_modules/@primer/octicons/build/svg/*-16.svg', {prefix: 'octicon'}),
52-
...processFiles('../web_src/svg/*.svg'),
53-
...processFiles('../public/img/gitea.svg', {fullName: 'gitea-gitea'}),
52+
...processFiles('node_modules/@primer/octicons/build/svg/*-16.svg', {prefix: 'octicon'}),
53+
...processFiles('web_src/svg/*.svg'),
54+
...processFiles('public/img/gitea.svg', {fullName: 'gitea-gitea'}),
5455
]);
5556
}
5657

5758
main().then(exit).catch(exit);
58-

cmd/admin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
asymkey_model "code.gitea.io/gitea/models/asymkey"
1818
"code.gitea.io/gitea/models/auth"
1919
"code.gitea.io/gitea/models/db"
20+
repo_model "code.gitea.io/gitea/models/repo"
2021
user_model "code.gitea.io/gitea/models/user"
2122
"code.gitea.io/gitea/modules/git"
2223
"code.gitea.io/gitea/modules/graceful"
@@ -722,9 +723,9 @@ func runRepoSyncReleases(_ *cli.Context) error {
722723

723724
log.Trace("Synchronizing repository releases (this may take a while)")
724725
for page := 1; ; page++ {
725-
repos, count, err := models.SearchRepositoryByName(&models.SearchRepoOptions{
726+
repos, count, err := repo_model.SearchRepositoryByName(&repo_model.SearchRepoOptions{
726727
ListOptions: db.ListOptions{
727-
PageSize: models.RepositoryListDefaultPageSize,
728+
PageSize: repo_model.RepositoryListDefaultPageSize,
728729
Page: page,
729730
},
730731
Private: true,

cmd/serv.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"code.gitea.io/gitea/modules/log"
2525
"code.gitea.io/gitea/modules/pprof"
2626
"code.gitea.io/gitea/modules/private"
27+
"code.gitea.io/gitea/modules/process"
2728
repo_module "code.gitea.io/gitea/modules/repository"
2829
"code.gitea.io/gitea/modules/setting"
2930
"code.gitea.io/gitea/services/lfs"
@@ -306,6 +307,7 @@ func runServ(c *cli.Context) error {
306307
}
307308
}
308309

310+
process.SetSysProcAttribute(gitcmd)
309311
gitcmd.Dir = setting.RepoRootPath
310312
gitcmd.Stdout = os.Stdout
311313
gitcmd.Stdin = os.Stdin

custom/conf/app.example.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,9 @@ PATH =
948948
;; List of keywords used in Pull Request comments to automatically reopen a related issue
949949
;REOPEN_KEYWORDS = reopen,reopens,reopened
950950
;;
951+
;; Set default merge style for repository creating, valid options: merge, rebase, rebase-merge, squash
952+
;DEFAULT_MERGE_STYLE = merge
953+
;;
951954
;; In the default merge message for squash commits include at most this many commits
952955
;DEFAULT_MERGE_MESSAGE_COMMITS_LIMIT = 50
953956
;;
@@ -2088,7 +2091,7 @@ PATH =
20882091
;[mirror]
20892092
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20902093
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2091-
;; Enables the mirror functionality. Set to **false** to disable all mirrors.
2094+
;; Enables the mirror functionality. Set to **false** to disable all mirrors. Pre-existing mirrors remain valid but won't be updated; may be converted to regular repo.
20922095
;ENABLED = true
20932096
;; Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
20942097
;DISABLE_NEW_PULL = false

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
9292
keywords used in Pull Request comments to automatically close a related issue
9393
- `REOPEN_KEYWORDS`: **reopen**, **reopens**, **reopened**: List of keywords used in Pull Request comments to automatically reopen
9494
a related issue
95+
- `DEFAULT_MERGE_STYLE`: **merge**: Set default merge style for repository creating, valid options: `merge`, `rebase`, `rebase-merge`, `squash`
9596
- `DEFAULT_MERGE_MESSAGE_COMMITS_LIMIT`: **50**: In the default merge message for squash commits include at most this many commits. Set to `-1` to include all commits
9697
- `DEFAULT_MERGE_MESSAGE_SIZE`: **5120**: In the default merge message for squash commits limit the size of the commit messages. Set to `-1` to have no limit. Only used if `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES` is `true`.
9798
- `DEFAULT_MERGE_MESSAGE_ALL_AUTHORS`: **false**: In the default merge message for squash commits walk all commits to include all authors in the Co-authored-by otherwise just use those in the limited list
@@ -1094,7 +1095,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
10941095

10951096
## Mirror (`mirror`)
10961097

1097-
- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors.
1098+
- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors. Pre-existing mirrors remain valid but won't be updated; may be converted to regular repo.
10981099
- `DISABLE_NEW_PULL`: **false**: Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
10991100
- `DISABLE_NEW_PUSH`: **false**: Disable the creation of **new** push mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
11001101
- `DEFAULT_INTERVAL`: **8h**: Default interval between each check

docs/content/doc/developers/guidelines-frontend.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/templa
2727

2828
The source files can be found in the following directories:
2929
* **Less styles:** `web_src/less/`
30-
* **Javascript files:** `web_src/js/`
31-
* **Vue layouts:** `web_src/js/components/`
32-
* **HTML templates:** `templates/`
30+
* **JavaScript files:** `web_src/js/`
31+
* **Vue components:** `web_src/js/components/`
32+
* **Go HTML templates:** `templates/`
3333

3434
## General Guidelines
3535

@@ -40,24 +40,29 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h
4040
1. Every feature (Fomantic-UI/jQuery module) should be put in separate files/directories.
4141
2. HTML ids and classes should use kebab-case.
4242
3. HTML ids and classes used in JavaScript should be unique for the whole project, and should contain 2-3 feature related keywords. We recommend to use the `js-` prefix for classes that are only used in JavaScript.
43-
4. jQuery events across different features should use their own namespaces.
44-
5. CSS styling for classes provided by frameworks should not be overwritten. Always use new class-names to overwrite framework styles. We recommend to use the `us-` prefix for user defined styles.
43+
4. jQuery events across different features could use their own namespaces if there are potential conflicts.
44+
5. CSS styling for classes provided by frameworks should not be overwritten. Always use new class-names with 2-3 feature related keywords to overwrite framework styles.
4545
6. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}`
4646
7. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue2 (or Vue3 in future).
4747

4848

4949
### Framework Usage
5050

51-
Mixing different frameworks together is highly discouraged. A JavaScript module should follow one major framework and follow the framework's best practice.
51+
Mixing different frameworks together is discouraged, it makes the code difficult to be maintained.
52+
A JavaScript module should follow one major framework and follow the framework's best practice.
5253

5354
Recommended implementations:
54-
* Vue + Native
55+
* Vue + Vanilla JS
5556
* Fomantic-UI (jQuery)
56-
* Native only
57+
* Vanilla JS
5758

5859
Discouraged implementations:
59-
* Vue + jQuery
60-
* jQuery + Native
60+
* Vue + Fomantic-UI (jQuery)
61+
* jQuery + Vanilla JS
62+
63+
To make UI consistent, Vue components can use Fomantic-UI CSS classes.
64+
Although mixing different frameworks is discouraged,
65+
it should also work if the mixing is necessary and the code is well-designed and maintainable.
6166

6267
### `async` Functions
6368

@@ -75,7 +80,8 @@ Some lint rules and IDEs also have warnings if the returned Promise is not handl
7580

7681
### HTML Attributes and `dataset`
7782

78-
We forbid `dataset` usage, its camel-casing behaviour makes it hard to grep for attributes. However there are still some special cases, so the current guideline is:
83+
The usage of `dataset` is forbidden, its camel-casing behaviour makes it hard to grep for attributes.
84+
However, there are still some special cases, so the current guideline is:
7985

8086
* For legacy code:
8187
* `$.data()` should be refactored to `$.attr()`.
@@ -86,6 +92,10 @@ We forbid `dataset` usage, its camel-casing behaviour makes it hard to grep for
8692
* never bind any user data to a DOM node, use a suitable design pattern to describe the relation between node and data.
8793

8894

95+
### Legacy Code
96+
97+
A lot of legacy code already existed before this document's written. It's recommended to refactor legacy code to follow the guidelines.
98+
8999
### Vue2/Vue3 and JSX
90100

91101
Gitea is using Vue2 now, we plan to upgrade to Vue3. We decided not to introduce JSX to keep the HTML and the JavaScript code separated.

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ require (
2929
github.com/go-chi/chi/v5 v5.0.7
3030
github.com/go-chi/cors v1.2.1
3131
github.com/go-enry/go-enry/v2 v2.8.2
32+
github.com/go-fed/httpsig v1.1.0
3233
github.com/go-git/go-billy/v5 v5.3.1
3334
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4
3435
github.com/go-ldap/ldap/v3 v3.4.3
@@ -98,8 +99,8 @@ require (
9899
gopkg.in/yaml.v2 v2.4.0
99100
mvdan.cc/xurls/v2 v2.4.0
100101
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
101-
xorm.io/builder v0.3.10
102-
xorm.io/xorm v1.2.5
102+
xorm.io/builder v0.3.11
103+
xorm.io/xorm v1.3.1
103104
)
104105

105106
require (

0 commit comments

Comments
 (0)