Skip to content

Commit 3ec0b96

Browse files
committed
Merge remote-tracking branch 'origin/main' into btnrow
* origin/main: (55 commits) Fix dashboard commit status null access (go-gitea#30771) Fix tautological conditions (go-gitea#30735) Get repo assignees and reviewers should ignore deactivated users (go-gitea#30770) Right align the "Settings" menu item in overflow-menu (go-gitea#30764) Fix duplicate status check contexts (go-gitea#30660) Fix issue label rendering in the issue popup (go-gitea#30763) Fix all rounded borders, change affected tab menus to pills (go-gitea#30707) Rename CodeIndexerEnabled to IsRepoIndexerEnabled (go-gitea#30762) Remove fomantic dimmer module (go-gitea#30723) Resolve lint for unused parameter and unnecessary type arguments (go-gitea#30750) Add support for npm bundleDependencies (go-gitea#30751) Fix cross-compilation errors when CGO_CFLAGS/CGO_LDFLAGS is set (go-gitea#30749) [skip ci] Updated licenses and gitignores add built js files to eslint ignore (go-gitea#30737) Gitea with first upper case + typos (go-gitea#30739) Fix documentation build problems because of MDX syntax conflicts (go-gitea#30744) Remove disk-clean workflow (go-gitea#30741) Bump `github.com/google/go-github` to v61 (go-gitea#30738) Fix nil dereference on error (go-gitea#30740) Use `ProtonMail/go-crypto` for `opengpg` in tests (go-gitea#30736) ...
2 parents 6760c5b + 5f05e7b commit 3ec0b96

File tree

231 files changed

+2326
-2701
lines changed

Some content is hidden

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

231 files changed

+2326
-2701
lines changed

.eslintrc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ reportUnusedDisableDirectives: true
44
ignorePatterns:
55
- /web_src/js/vendor
66
- /web_src/fomantic
7+
- /public/assets/js
78

89
parserOptions:
910
sourceType: module

.github/workflows/disk-clean.yml

-25
This file was deleted.

.github/workflows/release-nightly.yml

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
disk-clean:
13-
uses: ./.github/workflows/disk-clean.yml
1412
nightly-binary:
1513
runs-on: nscloud
1614
steps:

Makefile

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-che
3030
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0
3131
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
33-
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.4.1
33+
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.5.1
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@db51e79a0e37c572d8b59ae0c58bf2bbbbe53285
3535
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
3636
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
@@ -397,11 +397,11 @@ lint-md: node_modules
397397

398398
.PHONY: lint-spell
399399
lint-spell:
400-
@go run $(MISSPELL_PACKAGE) -error $(SPELLCHECK_FILES)
400+
@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -error $(SPELLCHECK_FILES)
401401

402402
.PHONY: lint-spell-fix
403403
lint-spell-fix:
404-
@go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES)
404+
@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -w $(SPELLCHECK_FILES)
405405

406406
.PHONY: lint-go
407407
lint-go:
@@ -778,7 +778,7 @@ generate-backend: $(TAGS_PREREQ) generate-go
778778
.PHONY: generate-go
779779
generate-go: $(TAGS_PREREQ)
780780
@echo "Running go generate..."
781-
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' ./...
781+
@CC= GOOS= GOARCH= CGO_ENABLED=0 $(GO) generate -tags '$(TAGS)' ./...
782782

783783
.PHONY: security-check
784784
security-check:
@@ -908,8 +908,9 @@ webpack: $(WEBPACK_DEST)
908908

909909
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
910910
@$(MAKE) -s node-check node_modules
911-
rm -rf $(WEBPACK_DEST_ENTRIES)
912-
npx webpack
911+
@rm -rf $(WEBPACK_DEST_ENTRIES)
912+
@echo "Running webpack..."
913+
@BROWSERSLIST_IGNORE_OLD_DATA=true npx webpack
913914
@touch $(WEBPACK_DEST)
914915

915916
.PHONY: svg

assets/go-licenses.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/admin_user_change_password.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var microcmdUserChangePassword = &cli.Command{
3535
},
3636
&cli.BoolFlag{
3737
Name: "must-change-password",
38-
Usage: "User must change password",
38+
Usage: "User must change password (can be disabled by --must-change-password=false)",
3939
Value: true,
4040
},
4141
},

cmd/admin_user_create.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cmd
55

66
import (
7+
"context"
78
"errors"
89
"fmt"
910

@@ -48,7 +49,7 @@ var microcmdUserCreate = &cli.Command{
4849
},
4950
&cli.BoolFlag{
5051
Name: "must-change-password",
51-
Usage: "Set to false to prevent forcing the user to change their password after initial login",
52+
Usage: "User must change password after initial login, defaults to true for all users except the first one (can be disabled by --must-change-password=false)",
5253
DisableDefaultText: true,
5354
},
5455
&cli.IntFlag{
@@ -91,11 +92,16 @@ func runCreateUser(c *cli.Context) error {
9192
_, _ = fmt.Fprintf(c.App.ErrWriter, "--name flag is deprecated. Use --username instead.\n")
9293
}
9394

94-
ctx, cancel := installSignals()
95-
defer cancel()
96-
97-
if err := initDB(ctx); err != nil {
98-
return err
95+
ctx := c.Context
96+
if !setting.IsInTesting {
97+
// FIXME: need to refactor the "installSignals/initDB" related code later
98+
// it doesn't make sense to call it in (almost) every command action function
99+
var cancel context.CancelFunc
100+
ctx, cancel = installSignals()
101+
defer cancel()
102+
if err := initDB(ctx); err != nil {
103+
return err
104+
}
99105
}
100106

101107
var password string
@@ -123,8 +129,8 @@ func runCreateUser(c *cli.Context) error {
123129
if err != nil {
124130
return fmt.Errorf("IsTableNotEmpty: %w", err)
125131
}
126-
if !hasUserRecord && isAdmin {
127-
// if this is the first admin being created, don't force to change password (keep the old behavior)
132+
if !hasUserRecord {
133+
// if this is the first one being created, don't force to change password (keep the old behavior)
128134
mustChangePassword = false
129135
}
130136
}

cmd/admin_user_create_test.go

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package cmd
5+
6+
import (
7+
"fmt"
8+
"strings"
9+
"testing"
10+
11+
"code.gitea.io/gitea/models/db"
12+
"code.gitea.io/gitea/models/unittest"
13+
user_model "code.gitea.io/gitea/models/user"
14+
15+
"github.com/stretchr/testify/assert"
16+
)
17+
18+
func TestAdminUserCreate(t *testing.T) {
19+
app := NewMainApp(AppVersion{})
20+
21+
reset := func() {
22+
assert.NoError(t, db.TruncateBeans(db.DefaultContext, &user_model.User{}))
23+
assert.NoError(t, db.TruncateBeans(db.DefaultContext, &user_model.EmailAddress{}))
24+
}
25+
26+
type createCheck struct{ IsAdmin, MustChangePassword bool }
27+
createUser := func(name, args string) createCheck {
28+
assert.NoError(t, app.Run(strings.Fields(fmt.Sprintf("./gitea admin user create --username %s --email %s@gitea.local %s --password foobar", name, name, args))))
29+
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{LowerName: name})
30+
return createCheck{u.IsAdmin, u.MustChangePassword}
31+
}
32+
reset()
33+
assert.Equal(t, createCheck{IsAdmin: false, MustChangePassword: false}, createUser("u", ""), "first non-admin user doesn't need to change password")
34+
35+
reset()
36+
assert.Equal(t, createCheck{IsAdmin: true, MustChangePassword: false}, createUser("u", "--admin"), "first admin user doesn't need to change password")
37+
38+
reset()
39+
assert.Equal(t, createCheck{IsAdmin: true, MustChangePassword: true}, createUser("u", "--admin --must-change-password"))
40+
assert.Equal(t, createCheck{IsAdmin: true, MustChangePassword: true}, createUser("u2", "--admin"))
41+
assert.Equal(t, createCheck{IsAdmin: true, MustChangePassword: false}, createUser("u3", "--admin --must-change-password=false"))
42+
assert.Equal(t, createCheck{IsAdmin: false, MustChangePassword: true}, createUser("u4", ""))
43+
assert.Equal(t, createCheck{IsAdmin: false, MustChangePassword: false}, createUser("u5", "--must-change-password=false"))
44+
}

cmd/main.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,18 @@ func prepareWorkPathAndCustomConf(action cli.ActionFunc) func(ctx *cli.Context)
112112
}
113113
}
114114

115-
func NewMainApp(version, versionExtra string) *cli.App {
115+
type AppVersion struct {
116+
Version string
117+
Extra string
118+
}
119+
120+
func NewMainApp(appVer AppVersion) *cli.App {
116121
app := cli.NewApp()
117122
app.Name = "Gitea"
118123
app.HelpName = "gitea"
119124
app.Usage = "A painless self-hosted Git service"
120125
app.Description = `Gitea program contains "web" and other subcommands. If no subcommand is given, it starts the web server by default. Use "web" subcommand for more web server arguments, use other subcommands for other purposes.`
121-
app.Version = version + versionExtra
126+
app.Version = appVer.Version + appVer.Extra
122127
app.EnableBashCompletion = true
123128

124129
// these sub-commands need to use config file

cmd/main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func makePathOutput(workPath, customPath, customConf string) string {
2828
}
2929

3030
func newTestApp(testCmdAction func(ctx *cli.Context) error) *cli.App {
31-
app := NewMainApp("version", "version-extra")
31+
app := NewMainApp(AppVersion{})
3232
testCmd := &cli.Command{Name: "test-cmd", Action: testCmdAction}
3333
prepareSubcommandWithConfig(testCmd, appGlobalFlags())
3434
app.Commands = append(app.Commands, testCmd)

contrib/backport/backport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"strings"
1818
"syscall"
1919

20-
"github.com/google/go-github/v57/github"
20+
"github.com/google/go-github/v61/github"
2121
"github.com/urfave/cli/v2"
2222
"gopkg.in/yaml.v3"
2323
)

custom/conf/app.example.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,8 @@ LEVEL = Info
15581558
;; email = use the username part of the email attribute
15591559
;; Note: `nickname`, `preferred_username` and `email` options will normalize input strings using the following criteria:
15601560
;; - diacritics are removed
1561-
;; - the characters in the set `['´\x60]` are removed
1562-
;; - the characters in the set `[\s~+]` are replaced with `-`
1561+
;; - the characters in the set ['´`] are removed
1562+
;; - the characters in the set [\s~+] are replaced with "-"
15631563
;USERNAME = nickname
15641564
;;
15651565
;; Update avatar if available from oauth2 provider.

docs/content/administration/config-cheat-sheet.en-us.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a
214214
- `SITEMAP_PAGING_NUM`: **20**: Number of items that are displayed in a single subsitemap.
215215
- `GRAPH_MAX_COMMIT_NUM`: **100**: Number of maximum commits shown in the commit graph.
216216
- `CODE_COMMENT_LINES`: **4**: Number of line of codes shown for a code comment.
217-
- `DEFAULT_THEME`: **gitea-auto**: Set the default theme for the Gitea installation, custom themes could be provided by "{CustomPath}/public/assets/css/theme-*.css".
217+
- `DEFAULT_THEME`: **gitea-auto**: Set the default theme for the Gitea installation, custom themes could be provided by `{CustomPath}/public/assets/css/theme-*.css`.
218218
- `SHOW_USER_EMAIL`: **true**: Whether the email of the user should be shown in the Explore Users page.
219-
- `THEMES`: **_empty_**: All available themes by "{CustomPath}/public/assets/css/theme-*.css". Allow users select personalized themes.
219+
- `THEMES`: **_empty_**: All available themes by `{CustomPath}/public/assets/css/theme-*.css`. Allow users select personalized themes.
220220
- `MAX_DISPLAY_FILE_SIZE`: **8388608**: Max size of files to be displayed (default is 8MiB)
221221
- `AMBIGUOUS_UNICODE_DETECTION`: **true**: Detect ambiguous unicode characters in file contents and show warnings on the UI
222222
- `REACTIONS`: All available reactions users can choose on issues/prs and comments
@@ -612,7 +612,7 @@ And the following unique queues:
612612
- `email` - use the username part of the email attribute
613613
- Note: `nickname`, `preferred_username` and `email` options will normalize input strings using the following criteria:
614614
- diacritics are removed
615-
- the characters in the set `['´\x60]` are removed
615+
- the characters in the set ```['´`]``` are removed
616616
- the characters in the set `[\s~+]` are replaced with `-`
617617
- `UPDATE_AVATAR`: **false**: Update avatar if available from oauth2 provider. Update will be performed on each login.
618618
- `ACCOUNT_LINKING`: **login**: How to handle if an account / email already exists:
@@ -1322,7 +1322,7 @@ Defaultly every storage has their default base path like below
13221322
| actions_log | actions_log/ |
13231323
| actions_artifacts | actions_artifacts/ |
13241324

1325-
And bucket, basepath or `SERVE_DIRECT` could be special or overrided, if you want to use a different you can:
1325+
And bucket, basepath or `SERVE_DIRECT` could be special or overridden, if you want to use a different you can:
13261326

13271327
```ini
13281328
[storage.actions_log]

docs/content/administration/config-cheat-sheet.zh-cn.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ menu:
212212
- `SITEMAP_PAGING_NUM`: **20**: 在单个子SiteMap中显示的项数。
213213
- `GRAPH_MAX_COMMIT_NUM`: **100**: 提交图中显示的最大commit数量。
214214
- `CODE_COMMENT_LINES`: **4**: 在代码评论中能够显示的最大代码行数。
215-
- `DEFAULT_THEME`: **gitea-auto**: 在Gitea安装时候设置的默认主题,自定义的主题可以通过 "{CustomPath}/public/assets/css/theme-*.css" 提供。
215+
- `DEFAULT_THEME`: **gitea-auto**: 在Gitea安装时候设置的默认主题,自定义的主题可以通过 `{CustomPath}/public/assets/css/theme-*.css` 提供。
216216
- `SHOW_USER_EMAIL`: **true**: 用户的电子邮件是否应该显示在`Explore Users`页面中。
217-
- `THEMES`: **_empty_**: 所有可用的主题(由 "{CustomPath}/public/assets/css/theme-*.css" 提供)。允许用户选择个性化的主题,
217+
- `THEMES`: **_empty_**: 所有可用的主题(由 `{CustomPath}/public/assets/css/theme-*.css` 提供)。允许用户选择个性化的主题,
218218
- `MAX_DISPLAY_FILE_SIZE`: **8388608**: 能够显示文件的最大大小(默认为8MiB)。
219219
- `REACTIONS`: 用户可以在问题(Issue)、Pull Request(PR)以及评论中选择的所有可选的反应。
220220
这些值可以是表情符号别名(例如::smile:)或Unicode表情符号。

docs/content/usage/repo-mirror.en-us.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The repository now gets mirrored periodically to the remote repository. You can
5858

5959
To set up a mirror from Gitea to GitHub, you need to follow these steps:
6060

61-
1. Create a [GitHub personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with the *public_repo* box checked. Also check the **workflow** checkbox in case your repo using act for continuous integration.
61+
1. Create a [GitHub personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with the *public_repo* box checked. Also check the **workflow** checkbox in case your repo uses GitHub Actions for continuous integration.
6262
2. Create a repository with that name on GitHub. Unlike Gitea, GitHub does not support creating repositories by pushing to the remote. You can also use an existing remote repo if it has the same commit history as your Gitea repo.
6363
3. In the settings of your Gitea repo, fill in the **Git Remote Repository URL**: `https://github.com/<your_github_group>/<your_github_project>.git`.
6464
4. Fill in the **Authorization** fields with your GitHub username and the personal access token as **Password**.
@@ -91,10 +91,10 @@ The repository pushes shortly thereafter. To force a push, select the **Synchron
9191

9292
### Mirror an existing ssh repository
9393

94-
Currently gitea supports no ssh push mirrors. You can work around this by adding a `post-receive` hook to your gitea repository that pushes manually.
94+
Currently Gitea supports no ssh push mirrors. You can work around this by adding a `post-receive` hook to your Gitea repository that pushes manually.
9595

96-
1. Make sure the user running gitea has access to the git repo you are trying to mirror to from shell.
97-
2. On the Webinterface at the repository settings > git hooks add a post-receive hook for the mirror. I.e.
96+
1. Make sure the user running Gitea has access to the git repo you are trying to mirror to from shell.
97+
2. On the web interface at the repository settings > git hooks add a post-receive hook for the mirror. I.e.
9898

9999
```
100100
#!/usr/bin/env bash

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4
1717
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121
1818
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
19+
github.com/ProtonMail/go-crypto v1.0.0
1920
github.com/PuerkitoBio/goquery v1.9.1
2021
github.com/alecthomas/chroma/v2 v2.13.0
2122
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
@@ -53,7 +54,7 @@ require (
5354
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
5455
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
5556
github.com/golang-jwt/jwt/v5 v5.2.1
56-
github.com/google/go-github/v57 v57.0.0
57+
github.com/google/go-github/v61 v61.0.0
5758
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7
5859
github.com/google/uuid v1.6.0
5960
github.com/gorilla/feeds v1.1.2
@@ -135,7 +136,6 @@ require (
135136
github.com/Masterminds/semver/v3 v3.2.1 // indirect
136137
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
137138
github.com/Microsoft/go-winio v0.6.1 // indirect
138-
github.com/ProtonMail/go-crypto v1.0.0 // indirect
139139
github.com/RoaringBitmap/roaring v1.9.0 // indirect
140140
github.com/andybalholm/brotli v1.1.0 // indirect
141141
github.com/andybalholm/cascadia v1.3.2 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
394394
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
395395
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
396396
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
397-
github.com/google/go-github/v57 v57.0.0 h1:L+Y3UPTY8ALM8x+TV0lg+IEBI+upibemtBD8Q9u7zHs=
398-
github.com/google/go-github/v57 v57.0.0/go.mod h1:s0omdnye0hvK/ecLvpsGfJMiRt85PimQh4oygmLIxHw=
397+
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
398+
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
399399
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
400400
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
401401
github.com/google/go-tpm v0.9.0 h1:sQF6YqWMi+SCXpsmS3fd21oPy/vSddwZry4JnmltHVk=

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
log.GetManager().Close()
4343
os.Exit(code)
4444
}
45-
app := cmd.NewMainApp(Version, formatBuiltWith())
45+
app := cmd.NewMainApp(cmd.AppVersion{Version: Version, Extra: formatBuiltWith()})
4646
_ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp
4747
log.GetManager().Close()
4848
}

0 commit comments

Comments
 (0)