Skip to content

Commit f42fcfe

Browse files
committed
Merge branch 'main' into lunny/add_webhook_test_compare_url
2 parents 4b2c4ac + bc28654 commit f42fcfe

File tree

178 files changed

+6310
-3133
lines changed

Some content is hidden

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

178 files changed

+6310
-3133
lines changed

.gitignore

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,10 @@ _testmain.go
4242
coverage.all
4343
cpu.out
4444

45-
/modules/migration/bindata.go
46-
/modules/migration/bindata.go.hash
47-
/modules/options/bindata.go
48-
/modules/options/bindata.go.hash
49-
/modules/public/bindata.go
50-
/modules/public/bindata.go.hash
51-
/modules/templates/bindata.go
52-
/modules/templates/bindata.go.hash
45+
/modules/migration/bindata.*
46+
/modules/options/bindata.*
47+
/modules/public/bindata.*
48+
/modules/templates/bindata.*
5349

5450
*.db
5551
*.log

CHANGELOG.md

Lines changed: 423 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
120120
WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
121121
WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
122122

123-
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
124-
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
123+
BINDATA_DEST := modules/public/bindata.dat modules/options/bindata.dat modules/templates/bindata.dat
125124

126125
GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go
127126

@@ -149,14 +148,8 @@ SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) templates options/locale/locale_en-US
149148
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
150149

151150
GO_SOURCES := $(wildcard *.go)
152-
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
151+
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go")
153152
GO_SOURCES += $(GENERATED_GO_DEST)
154-
GO_SOURCES_NO_BINDATA := $(GO_SOURCES)
155-
156-
ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
157-
GO_SOURCES += $(BINDATA_DEST)
158-
GENERATED_GO_DEST += $(BINDATA_DEST)
159-
endif
160153

161154
# Force installation of playwright dependencies by setting this flag
162155
ifdef DEPS_PLAYWRIGHT
@@ -226,7 +219,7 @@ clean-all: clean ## delete backend, frontend and integration files
226219

227220
.PHONY: clean
228221
clean: ## delete backend and integration files
229-
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
222+
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) \
230223
integrations*.test \
231224
e2e*.test \
232225
tests/integration/gitea-integration-* \
@@ -268,7 +261,7 @@ endif
268261
.PHONY: generate-swagger
269262
generate-swagger: $(SWAGGER_SPEC) ## generate the swagger spec from code comments
270263

271-
$(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA) $(SWAGGER_SPEC_INPUT)
264+
$(SWAGGER_SPEC): $(GO_SOURCES) $(SWAGGER_SPEC_INPUT)
272265
$(GO) run $(SWAGGER_PACKAGE) generate spec --exclude "$(SWAGGER_EXCLUDE)" --input "$(SWAGGER_SPEC_INPUT)" --output './$(SWAGGER_SPEC)'
273266

274267
.PHONY: swagger-check
@@ -373,7 +366,7 @@ lint-go-gitea-vet: ## lint go files with gitea-vet
373366
.PHONY: lint-go-gopls
374367
lint-go-gopls: ## lint go files with gopls
375368
@echo "Running gopls check..."
376-
@GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES_NO_BINDATA)
369+
@GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES)
377370

378371
.PHONY: lint-editorconfig
379372
lint-editorconfig:

assets/go-licenses.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,10 @@
55

66
package main
77

8-
// Libraries that are included to vendor utilities used during build.
8+
// Libraries that are included to vendor utilities used during Makefile build.
99
// These libraries will not be included in a normal compilation.
1010

1111
import (
12-
// for embed
13-
_ "github.com/shurcooL/vfsgen"
14-
15-
// for cover merge
16-
_ "golang.org/x/tools/cover"
17-
1812
// for vet
1913
_ "code.gitea.io/gitea-vet"
20-
21-
// for swagger
22-
_ "github.com/go-swagger/go-swagger/cmd/swagger"
2314
)

build/generate-bindata.go

Lines changed: 9 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -6,87 +6,22 @@
66
package main
77

88
import (
9-
"bytes"
10-
"crypto/sha1"
119
"fmt"
12-
"log"
13-
"net/http"
1410
"os"
15-
"path/filepath"
16-
"strconv"
1711

18-
"github.com/shurcooL/vfsgen"
12+
"code.gitea.io/gitea/modules/assetfs"
1913
)
2014

21-
func needsUpdate(dir, filename string) (bool, []byte) {
22-
needRegen := false
23-
_, err := os.Stat(filename)
24-
if err != nil {
25-
needRegen = true
26-
}
27-
28-
oldHash, err := os.ReadFile(filename + ".hash")
29-
if err != nil {
30-
oldHash = []byte{}
31-
}
32-
33-
hasher := sha1.New()
34-
35-
err = filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
36-
if err != nil {
37-
return err
38-
}
39-
info, err := d.Info()
40-
if err != nil {
41-
return err
42-
}
43-
_, _ = hasher.Write([]byte(d.Name()))
44-
_, _ = hasher.Write([]byte(info.ModTime().String()))
45-
_, _ = hasher.Write([]byte(strconv.FormatInt(info.Size(), 16)))
46-
return nil
47-
})
48-
if err != nil {
49-
return true, oldHash
50-
}
51-
52-
newHash := hasher.Sum([]byte{})
53-
54-
if bytes.Compare(oldHash, newHash) != 0 {
55-
return true, newHash
56-
}
57-
58-
return needRegen, newHash
59-
}
60-
6115
func main() {
62-
if len(os.Args) < 4 {
63-
log.Fatal("Insufficient number of arguments. Need: directory packageName filename")
64-
}
65-
66-
dir, packageName, filename := os.Args[1], os.Args[2], os.Args[3]
67-
var useGlobalModTime bool
68-
if len(os.Args) == 5 {
69-
useGlobalModTime, _ = strconv.ParseBool(os.Args[4])
70-
}
71-
72-
update, newHash := needsUpdate(dir, filename)
73-
74-
if !update {
75-
fmt.Printf("bindata for %s already up-to-date\n", packageName)
76-
return
16+
if len(os.Args) != 3 {
17+
fmt.Println("usage: ./generate-bindata {local-directory} {bindata-filename}")
18+
os.Exit(1)
7719
}
7820

79-
fmt.Printf("generating bindata for %s\n", packageName)
80-
var fsTemplates http.FileSystem = http.Dir(dir)
81-
err := vfsgen.Generate(fsTemplates, vfsgen.Options{
82-
PackageName: packageName,
83-
BuildTags: "bindata",
84-
VariableName: "Assets",
85-
Filename: filename,
86-
UseGlobalModTime: useGlobalModTime,
87-
})
88-
if err != nil {
89-
log.Fatalf("%v\n", err)
21+
dir, filename := os.Args[1], os.Args[2]
22+
fmt.Printf("generating bindata for %s to %s\n", dir, filename)
23+
if err := assetfs.GenerateEmbedBindata(dir, filename); err != nil {
24+
fmt.Printf("failed: %s\n", err.Error())
25+
os.Exit(1)
9026
}
91-
_ = os.WriteFile(filename+".hash", newHash, 0o666)
9227
}

cmd/actions.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
package cmd
55

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

910
"code.gitea.io/gitea/modules/private"
1011
"code.gitea.io/gitea/modules/setting"
1112

12-
"github.com/urfave/cli/v2"
13+
"github.com/urfave/cli/v3"
1314
)
1415

1516
var (
1617
// CmdActions represents the available actions sub-commands.
1718
CmdActions = &cli.Command{
1819
Name: "actions",
1920
Usage: "Manage Gitea Actions",
20-
Subcommands: []*cli.Command{
21+
Commands: []*cli.Command{
2122
subcmdActionsGenRunnerToken,
2223
},
2324
}
@@ -38,10 +39,7 @@ var (
3839
}
3940
)
4041

41-
func runGenerateActionsRunnerToken(c *cli.Context) error {
42-
ctx, cancel := installSignals()
43-
defer cancel()
44-
42+
func runGenerateActionsRunnerToken(ctx context.Context, c *cli.Command) error {
4543
setting.MustInstalled()
4644

4745
scope := c.String("scope")

cmd/admin.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ import (
1515
"code.gitea.io/gitea/modules/log"
1616
repo_module "code.gitea.io/gitea/modules/repository"
1717

18-
"github.com/urfave/cli/v2"
18+
"github.com/urfave/cli/v3"
1919
)
2020

2121
var (
2222
// CmdAdmin represents the available admin sub-command.
2323
CmdAdmin = &cli.Command{
2424
Name: "admin",
2525
Usage: "Perform common administrative operations",
26-
Subcommands: []*cli.Command{
26+
Commands: []*cli.Command{
2727
subcmdUser,
2828
subcmdRepoSyncReleases,
2929
subcmdRegenerate,
@@ -41,7 +41,7 @@ var (
4141
subcmdRegenerate = &cli.Command{
4242
Name: "regenerate",
4343
Usage: "Regenerate specific files",
44-
Subcommands: []*cli.Command{
44+
Commands: []*cli.Command{
4545
microcmdRegenHooks,
4646
microcmdRegenKeys,
4747
},
@@ -50,15 +50,15 @@ var (
5050
subcmdAuth = &cli.Command{
5151
Name: "auth",
5252
Usage: "Modify external auth providers",
53-
Subcommands: []*cli.Command{
54-
microcmdAuthAddOauth,
55-
microcmdAuthUpdateOauth,
56-
microcmdAuthAddLdapBindDn,
57-
microcmdAuthUpdateLdapBindDn,
58-
microcmdAuthAddLdapSimpleAuth,
59-
microcmdAuthUpdateLdapSimpleAuth,
60-
microcmdAuthAddSMTP,
61-
microcmdAuthUpdateSMTP,
53+
Commands: []*cli.Command{
54+
microcmdAuthAddOauth(),
55+
microcmdAuthUpdateOauth(),
56+
microcmdAuthAddLdapBindDn(),
57+
microcmdAuthUpdateLdapBindDn(),
58+
microcmdAuthAddLdapSimpleAuth(),
59+
microcmdAuthUpdateLdapSimpleAuth(),
60+
microcmdAuthAddSMTP(),
61+
microcmdAuthUpdateSMTP(),
6262
microcmdAuthList,
6363
microcmdAuthDelete,
6464
},
@@ -70,9 +70,9 @@ var (
7070
Action: runSendMail,
7171
Flags: []cli.Flag{
7272
&cli.StringFlag{
73-
Name: "title",
74-
Usage: `a title of a message`,
75-
Value: "",
73+
Name: "title",
74+
Usage: "a title of a message",
75+
Required: true,
7676
},
7777
&cli.StringFlag{
7878
Name: "content",
@@ -86,17 +86,16 @@ var (
8686
},
8787
},
8888
}
89+
)
8990

90-
idFlag = &cli.Int64Flag{
91+
func idFlag() *cli.Int64Flag {
92+
return &cli.Int64Flag{
9193
Name: "id",
9294
Usage: "ID of authentication source",
9395
}
94-
)
95-
96-
func runRepoSyncReleases(_ *cli.Context) error {
97-
ctx, cancel := installSignals()
98-
defer cancel()
96+
}
9997

98+
func runRepoSyncReleases(ctx context.Context, _ *cli.Command) error {
10099
if err := initDB(ctx); err != nil {
101100
return err
102101
}

cmd/admin_auth.go

Lines changed: 5 additions & 10 deletions
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
"os"
@@ -13,14 +14,14 @@ import (
1314
"code.gitea.io/gitea/models/db"
1415
auth_service "code.gitea.io/gitea/services/auth"
1516

16-
"github.com/urfave/cli/v2"
17+
"github.com/urfave/cli/v3"
1718
)
1819

1920
var (
2021
microcmdAuthDelete = &cli.Command{
2122
Name: "delete",
2223
Usage: "Delete specific auth source",
23-
Flags: []cli.Flag{idFlag},
24+
Flags: []cli.Flag{idFlag()},
2425
Action: runDeleteAuth,
2526
}
2627
microcmdAuthList = &cli.Command{
@@ -56,10 +57,7 @@ var (
5657
}
5758
)
5859

59-
func runListAuth(c *cli.Context) error {
60-
ctx, cancel := installSignals()
61-
defer cancel()
62-
60+
func runListAuth(ctx context.Context, c *cli.Command) error {
6361
if err := initDB(ctx); err != nil {
6462
return err
6563
}
@@ -90,14 +88,11 @@ func runListAuth(c *cli.Context) error {
9088
return nil
9189
}
9290

93-
func runDeleteAuth(c *cli.Context) error {
91+
func runDeleteAuth(ctx context.Context, c *cli.Command) error {
9492
if !c.IsSet("id") {
9593
return errors.New("--id flag is missing")
9694
}
9795

98-
ctx, cancel := installSignals()
99-
defer cancel()
100-
10196
if err := initDB(ctx); err != nil {
10297
return err
10398
}

0 commit comments

Comments
 (0)