Skip to content

Commit 33504f4

Browse files
Merge branch 'master' into search_type
2 parents 38996b6 + 4fbe645 commit 33504f4

File tree

373 files changed

+16116
-3447
lines changed

Some content is hidden

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

373 files changed

+16116
-3447
lines changed

.changelog.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ groups:
2222
name: SECURITY
2323
labels:
2424
- kind/security
25+
-
26+
name: API
27+
labels:
28+
- kind/api
2529
-
2630
name: BUGFIXES
2731
labels:

.drone.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,6 @@ services:
113113
environment:
114114
MYSQL_ALLOW_EMPTY_PASSWORD: yes
115115
MYSQL_DATABASE: test
116-
GOPROXY: off
117-
TAGS: bindata sqlite sqlite_unlock_notify
118-
GITLAB_READ_TOKEN:
119-
from_secret: gitlab_read_token
120-
depends_on:
121-
- build
122-
when:
123-
branch:
124-
- master
125-
event:
126-
- push
127-
- pull_request
128116

129117
- name: mysql8
130118
pull: default
@@ -152,7 +140,7 @@ services:
152140
image: elasticsearch:7.5.0
153141

154142
- name: minio
155-
image: minio/minio:RELEASE.2020-05-16T01-33-21Z
143+
image: minio/minio:RELEASE.2020-10-09T22-55-05Z
156144
commands:
157145
- minio server /data
158146
environment:

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,9 @@ issues:
101101
- path: cmd/dump.go
102102
linters:
103103
- dupl
104+
- text: "commentFormatting: put a space between `//` and comment text"
105+
linters:
106+
- gocritic
107+
- text: "exitAfterDefer:"
108+
linters:
109+
- gocritic

CHANGELOG.md

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

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,12 @@ endif
120120

121121
GO_SOURCES_OWN := $(filter-out vendor/% %/bindata.go, $(GO_SOURCES))
122122

123-
#To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger@v0.20.1
123+
#To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger
124124
SWAGGER := $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger
125125
SWAGGER_SPEC := templates/swagger/v1_json.tmpl
126126
SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl}}/api/v1"|g
127127
SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g
128+
SWAGGER_EXCLUDE := code.gitea.io/sdk
128129
SWAGGER_NEWLINE_COMMAND := -e '$$a\'
129130

130131
TEST_MYSQL_HOST ?= mysql:3306
@@ -185,7 +186,7 @@ help:
185186

186187
.PHONY: go-check
187188
go-check:
188-
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell go version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
189+
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
189190
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
190191
echo "Gitea requires Go 1.13 or greater to build. You can get it at https://golang.org/dl/"; \
191192
exit 1; \
@@ -243,7 +244,7 @@ endif
243244

244245
.PHONY: generate-swagger
245246
generate-swagger:
246-
$(SWAGGER) generate spec -o './$(SWAGGER_SPEC)'
247+
$(SWAGGER) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
247248
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
248249
$(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
249250

@@ -697,7 +698,7 @@ pr\#%: clean-all
697698
golangci-lint:
698699
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
699700
export BINARY="golangci-lint"; \
700-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.30.0; \
701+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.31.0; \
701702
fi
702703
golangci-lint run --timeout 5m
703704

cmd/hook.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ func runHookUpdate(c *cli.Context) error {
285285
}
286286

287287
func runHookPostReceive(c *cli.Context) error {
288+
// First of all run update-server-info no matter what
289+
if _, err := git.NewCommand("update-server-info").Run(); err != nil {
290+
return fmt.Errorf("Failed to call 'git update-server-info': %v", err)
291+
}
292+
293+
// Now if we're an internal don't do anything else
288294
if os.Getenv(models.EnvIsInternal) == "true" {
289295
return nil
290296
}

cmd/migrate_storage.go

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ var CmdMigrateStorage = cli.Command{
3232
},
3333
cli.StringFlag{
3434
Name: "storage, s",
35-
Value: setting.LocalStorageType,
36-
Usage: "New storage type, local or minio",
35+
Value: "",
36+
Usage: "New storage type: local (default) or minio",
3737
},
3838
cli.StringFlag{
3939
Name: "path, p",
@@ -91,6 +91,20 @@ func migrateLFS(dstStorage storage.ObjectStorage) error {
9191
})
9292
}
9393

94+
func migrateAvatars(dstStorage storage.ObjectStorage) error {
95+
return models.IterateUser(func(user *models.User) error {
96+
_, err := storage.Copy(dstStorage, user.CustomAvatarRelativePath(), storage.Avatars, user.CustomAvatarRelativePath())
97+
return err
98+
})
99+
}
100+
101+
func migrateRepoAvatars(dstStorage storage.ObjectStorage) error {
102+
return models.IterateRepository(func(repo *models.Repository) error {
103+
_, err := storage.Copy(dstStorage, repo.CustomAvatarRelativePath(), storage.RepoAvatars, repo.CustomAvatarRelativePath())
104+
return err
105+
})
106+
}
107+
94108
func runMigrateStorage(ctx *cli.Context) error {
95109
if err := initDB(); err != nil {
96110
return err
@@ -107,35 +121,43 @@ func runMigrateStorage(ctx *cli.Context) error {
107121
return err
108122
}
109123

124+
goCtx := context.Background()
125+
110126
if err := storage.Init(); err != nil {
111127
return err
112128
}
113129

114130
var dstStorage storage.ObjectStorage
115131
var err error
116132
switch strings.ToLower(ctx.String("storage")) {
117-
case setting.LocalStorageType:
133+
case "":
134+
fallthrough
135+
case string(storage.LocalStorageType):
118136
p := ctx.String("path")
119137
if p == "" {
120138
log.Fatal("Path must be given when storage is loal")
121139
return nil
122140
}
123-
dstStorage, err = storage.NewLocalStorage(p)
124-
case setting.MinioStorageType:
141+
dstStorage, err = storage.NewLocalStorage(
142+
goCtx,
143+
storage.LocalStorageConfig{
144+
Path: p,
145+
})
146+
case string(storage.MinioStorageType):
125147
dstStorage, err = storage.NewMinioStorage(
126-
context.Background(),
127-
ctx.String("minio-endpoint"),
128-
ctx.String("minio-access-key-id"),
129-
ctx.String("minio-secret-access-key"),
130-
ctx.String("minio-bucket"),
131-
ctx.String("minio-location"),
132-
ctx.String("minio-base-path"),
133-
ctx.Bool("minio-use-ssl"),
134-
)
148+
goCtx,
149+
storage.MinioStorageConfig{
150+
Endpoint: ctx.String("minio-endpoint"),
151+
AccessKeyID: ctx.String("minio-access-key-id"),
152+
SecretAccessKey: ctx.String("minio-secret-access-key"),
153+
Bucket: ctx.String("minio-bucket"),
154+
Location: ctx.String("minio-location"),
155+
BasePath: ctx.String("minio-base-path"),
156+
UseSSL: ctx.Bool("minio-use-ssl"),
157+
})
135158
default:
136-
return fmt.Errorf("Unsupported attachments storage type: %s", ctx.String("storage"))
159+
return fmt.Errorf("Unsupported storage type: %s", ctx.String("storage"))
137160
}
138-
139161
if err != nil {
140162
return err
141163
}
@@ -150,6 +172,14 @@ func runMigrateStorage(ctx *cli.Context) error {
150172
if err := migrateLFS(dstStorage); err != nil {
151173
return err
152174
}
175+
case "avatars":
176+
if err := migrateAvatars(dstStorage); err != nil {
177+
return err
178+
}
179+
case "repo-avatars":
180+
if err := migrateRepoAvatars(dstStorage); err != nil {
181+
return err
182+
}
153183
default:
154184
return fmt.Errorf("Unsupported storage: %s", ctx.String("type"))
155185
}

cmd/serv.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ func setup(logPath string, debug bool) {
5454
_ = log.DelLogger("console")
5555
if debug {
5656
_ = log.NewLogger(1000, "console", "console", `{"level":"trace","stacktracelevel":"NONE","stderr":true}`)
57+
} else {
58+
_ = log.NewLogger(1000, "console", "console", `{"level":"fatal","stacktracelevel":"NONE","stderr":true}`)
5759
}
5860
setting.NewContext()
5961
if debug {
@@ -111,9 +113,12 @@ func runServ(c *cli.Context) error {
111113
if err != nil {
112114
fail("Internal error", "Failed to check provided key: %v", err)
113115
}
114-
if key.Type == models.KeyTypeDeploy {
116+
switch key.Type {
117+
case models.KeyTypeDeploy:
115118
println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Gitea does not provide shell access.")
116-
} else {
119+
case models.KeyTypePrincipal:
120+
println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Gitea does not provide shell access.")
121+
default:
117122
println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.")
118123
}
119124
println("If this is unexpected, please log in with password and setup Gitea under another user.")

cmd/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
9393
// Remove the trailing slash at the end of setting.AppURL, the request
9494
// URI always contains a leading slash, which would result in a double
9595
// slash
96-
target := strings.TrimRight(setting.AppURL, "/") + r.URL.RequestURI()
96+
target := strings.TrimSuffix(setting.AppURL, "/") + r.URL.RequestURI()
9797
http.Redirect(w, r, target, http.StatusFound)
9898
}
9999

contrib/ide/vscode/tasks.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
"focus": false,
1313
"panel": "shared"
1414
},
15-
"args": ["build"],
1615
"linux": {
17-
"args": [ "-o", "gitea", "${workspaceRoot}/main.go" ]
16+
"args": ["build", "-o", "gitea", "${workspaceRoot}/main.go" ]
1817
},
1918
"osx": {
20-
"args": [ "-o", "gitea", "${workspaceRoot}/main.go" ]
19+
"args": ["build", "-o", "gitea", "${workspaceRoot}/main.go" ]
2120
},
2221
"windows": {
23-
"args": [ "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
22+
"args": ["build", "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
2423
},
2524
"problemMatcher": ["$go"]
2625
},
@@ -35,15 +34,14 @@
3534
"focus": false,
3635
"panel": "shared"
3736
},
38-
"args": ["build", "-tags=\"sqlite sqlite_unlock_notify\""],
3937
"linux": {
40-
"args": ["-o", "gitea", "${workspaceRoot}/main.go"]
38+
"args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea", "${workspaceRoot}/main.go"]
4139
},
4240
"osx": {
43-
"args": ["-o", "gitea", "${workspaceRoot}/main.go"]
41+
"args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea", "${workspaceRoot}/main.go"]
4442
},
4543
"windows": {
46-
"args": ["-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
44+
"args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
4745
},
4846
"problemMatcher": ["$go"]
4947
}

0 commit comments

Comments
 (0)