Skip to content

Commit 1327a6a

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Improve the performance when detecting the file editable (go-gitea#34653) Fix various problems (go-gitea#34708) Refactor embedded assets and drop unnecessary dependencies (go-gitea#34692) Bump minimum go version to 1.24.4 (go-gitea#34699) Update JS deps (go-gitea#34701) Fix markdown wrap (go-gitea#34697) [skip ci] Updated translations via Crowdin frontport changelog (go-gitea#34689) Improve instance wide ssh commit signing (go-gitea#34341)
2 parents 17d7023 + bc28654 commit 1327a6a

Some content is hidden

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

60 files changed

+2552
-1371
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:

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/embedded.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,23 @@ func initEmbeddedExtractor(c *cli.Command) error {
118118

119119
func runList(_ context.Context, c *cli.Command) error {
120120
if err := runListDo(c); err != nil {
121-
fmt.Fprintf(os.Stderr, "%v\n", err)
121+
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
122122
return err
123123
}
124124
return nil
125125
}
126126

127127
func runView(_ context.Context, c *cli.Command) error {
128128
if err := runViewDo(c); err != nil {
129-
fmt.Fprintf(os.Stderr, "%v\n", err)
129+
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
130130
return err
131131
}
132132
return nil
133133
}
134134

135135
func runExtract(_ context.Context, c *cli.Command) error {
136136
if err := runExtractDo(c); err != nil {
137-
fmt.Fprintf(os.Stderr, "%v\n", err)
137+
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
138138
return err
139139
}
140140
return nil
@@ -217,7 +217,7 @@ func runExtractDo(c *cli.Command) error {
217217
for _, a := range matchedAssetFiles {
218218
if err := extractAsset(destdir, a, overwrite, rename); err != nil {
219219
// Non-fatal error
220-
fmt.Fprintf(os.Stderr, "%s: %v", a.path, err)
220+
_, _ = fmt.Fprintf(os.Stderr, "%s: %v\n", a.path, err)
221221
}
222222
}
223223

cmd/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func runServ(ctx context.Context, c *cli.Command) error {
212212
if git.DefaultFeatures().SupportProcReceive {
213213
// for AGit Flow
214214
if cmd == "ssh_info" {
215-
fmt.Print(`{"type":"gitea","version":1}`)
215+
fmt.Print(`{"type":"agit","version":1}`)
216216
return nil
217217
}
218218
}

custom/conf/app.example.ini

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,17 +1186,24 @@ LEVEL = Info
11861186
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11871187
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11881188
;;
1189-
;; GPG key to use to sign commits, Defaults to the default - that is the value of git config --get user.signingkey
1189+
;; GPG or SSH key to use to sign commits, Defaults to the default - that is the value of git config --get user.signingkey
1190+
;; Depending on the value of SIGNING_FORMAT this is either:
1191+
;; - openpgp: the GPG key ID
1192+
;; - ssh: the path to the ssh public key "/path/to/key.pub": where "/path/to/key" is the private key, use ssh-keygen -t ed25519 to generate a new key pair without password
11901193
;; run in the context of the RUN_USER
11911194
;; Switch to none to stop signing completely
11921195
;SIGNING_KEY = default
11931196
;;
1194-
;; If a SIGNING_KEY ID is provided and is not set to default, use the provided Name and Email address as the signer.
1197+
;; If a SIGNING_KEY ID is provided and is not set to default, use the provided Name and Email address as the signer and the signing format.
11951198
;; These should match a publicized name and email address for the key. (When SIGNING_KEY is default these are set to
1196-
;; the results of git config --get user.name and git config --get user.email respectively and can only be overridden
1199+
;; the results of git config --get user.name, git config --get user.email and git config --default openpgp --get gpg.format respectively and can only be overridden
11971200
;; by setting the SIGNING_KEY ID to the correct ID.)
11981201
;SIGNING_NAME =
11991202
;SIGNING_EMAIL =
1203+
;; SIGNING_FORMAT can be one of:
1204+
;; - openpgp (default): use GPG to sign commits
1205+
;; - ssh: use SSH to sign commits
1206+
;SIGNING_FORMAT = openpgp
12001207
;;
12011208
;; Sets the default trust model for repositories. Options are: collaborator, committer, collaboratorcommitter
12021209
;DEFAULT_TRUST_MODEL = collaborator
@@ -1223,6 +1230,13 @@ LEVEL = Info
12231230
;; - commitssigned: require that all the commits in the head branch are signed.
12241231
;; - approved: only sign when merging an approved pr to a protected branch
12251232
;MERGES = pubkey, twofa, basesigned, commitssigned
1233+
;;
1234+
;; Determines which additional ssh keys are trusted for all signed commits regardless of the user
1235+
;; This is useful for ssh signing key rotation.
1236+
;; Exposes the provided SIGNING_NAME and SIGNING_EMAIL as the signer, regardless of the SIGNING_FORMAT value.
1237+
;; Multiple keys should be comma separated.
1238+
;; E.g."ssh-<algorithm> <key>". or "ssh-<algorithm> <key1>, ssh-<algorithm> <key2>".
1239+
;TRUSTED_SSH_KEYS =
12261240

12271241
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12281242
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

0 commit comments

Comments
 (0)