Skip to content

Commit 0442361

Browse files
authored
Merge branch 'main' into 16457_wiki_webhook
2 parents def6afe + e4addac commit 0442361

File tree

386 files changed

+7744
-7747
lines changed

Some content is hidden

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

386 files changed

+7744
-7747
lines changed

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,7 @@ issues:
171171
- path: models/user/openid.go
172172
linters:
173173
- golint
174+
- path: models/user/badge.go
175+
linters:
176+
- revive
177+
text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge"

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,45 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7+
## [1.17.1](https://github.com/go-gitea/gitea/releases/tag/1.17.1) - 2022-08-17
8+
9+
* SECURITY
10+
* Correctly escape within tribute.js (#20831) (#20832)
11+
* ENHANCEMENTS
12+
* Add support for NuGet API keys (#20721) (#20734)
13+
* Display project in issue list (#20583)
14+
* Add disable download source configuration (#20548) (#20579)
15+
* Add username check to doctor (#20140) (#20671)
16+
* Enable Wire 2 for Internal SSH Server (#20616) (#20617)
17+
* BUGFIXES
18+
* Use the total issue count for UI (#20785) (#20827)
19+
* Add proxy host into allow list (#20798) (#20819)
20+
* Add missing translation for queue flush workers (#20791) (#20792)
21+
* Improve comment header for mobile (#20781) (#20789)
22+
* Fix git.Init for doctor sub-command (#20782) (#20783)
23+
* Check webhooks slice length before calling xorm (#20642) (#20768)
24+
* Remove manual rollback for failed generated repositories (#20639) (#20762)
25+
* Use correct field name in npm template (#20675) (#20760)
26+
* Keep download count on Container tag overwrite (#20728) (#20735)
27+
* Fix v220 migration to be compatible for MSSQL 2008 r2 (#20702) (#20707)
28+
* Use request timeout for git service rpc (#20689) (#20693)
29+
* Send correct NuGet status codes (#20647) (#20677)
30+
* Use correct context to get package content (#20673) (#20676)
31+
* Fix the JS error "EventSource is not defined" caused by some non-standard browsers (#20584) (#20663)
32+
* Add default commit messages to PR for squash merge (#20618) (#20645)
33+
* Fix package upload for files >32mb (#20622) (#20635)
34+
* Fix the new-line copy-paste for rendered code (#20612)
35+
* Clean up and fix clone button script (#20415 & #20600) (#20599)
36+
* Fix default merge style (#20564) (#20565)
37+
* Add repository condition for issue count (#20454) (#20496)
38+
* Make branch icon stand out more (#20726) (#20774)
39+
* Fix loading button with invalid form (#20754) (#20759)
40+
* Fix SecToTime edge-cases (#20610) (#20611)
41+
* Executable check always returns true for windows (#20637) (#20835)
42+
* Check issue labels slice length before calling xorm Insert (#20655) (#20836)
43+
* Fix owners cannot create organization repos bug (#20841) (#20854)
44+
* Prevent 500 is head repo does not have PullRequest unit in IsUserAllowedToUpdate (#20839) (#20848)
45+
746
## [1.17.0](https://github.com/go-gitea/gitea/releases/tag/v1.17.0) - 2022-07-30
847

948
* BREAKING

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ clean:
242242

243243
.PHONY: fmt
244244
fmt:
245-
@echo "Running gitea-fmt (with gofumpt)..."
246245
@MISSPELL_PACKAGE=$(MISSPELL_PACKAGE) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
246+
$(eval TEMPLATES := $(wildcard templates/**/*.tmpl))
247+
@# strip whitespace after '{{' and before `}}` unless there is only whitespace before it
248+
@$(SED_INPLACE) -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' $(TEMPLATES)
247249

248250
.PHONY: vet
249251
vet:
@@ -288,13 +290,19 @@ errcheck:
288290

289291
.PHONY: fmt-check
290292
fmt-check:
291-
# get all go files and run gitea-fmt (with gofmt) on them
293+
@# get all go files and run gitea-fmt (with gofmt) on them
292294
@diff=$$(MISSPELL_PACKAGE=$(MISSPELL_PACKAGE) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -l '{file-list}'); \
293295
if [ -n "$$diff" ]; then \
294296
echo "Please run 'make fmt' and commit the result:"; \
295297
echo "$${diff}"; \
296298
exit 1; \
297299
fi
300+
@diff2=$$(git diff templates); \
301+
if [ -n "$$diff2" ]; then \
302+
echo "Please run 'make fmt' and commit the result:"; \
303+
echo "$${diff2}"; \
304+
exit 1; \
305+
fi
298306

299307
.PHONY: checks
300308
checks: checks-frontend checks-backend

build/generate-licenses.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ func main() {
3939

4040
defer util.Remove(file.Name())
4141

42+
if err := os.RemoveAll(destination); err != nil {
43+
log.Fatalf("Cannot clean destination folder: %v", err)
44+
}
45+
46+
if err := os.MkdirAll(destination, 0o755); err != nil {
47+
log.Fatalf("Cannot create destination: %v", err)
48+
}
49+
4250
req, err := http.NewRequest("GET", url, nil)
4351
if err != nil {
4452
log.Fatalf("Failed to download archive. %s", err)

build/gitea-format-imports.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

cmd/admin.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import (
1313
"strings"
1414
"text/tabwriter"
1515

16-
"code.gitea.io/gitea/models"
1716
asymkey_model "code.gitea.io/gitea/models/asymkey"
18-
"code.gitea.io/gitea/models/auth"
17+
auth_model "code.gitea.io/gitea/models/auth"
1918
"code.gitea.io/gitea/models/db"
2019
repo_model "code.gitea.io/gitea/models/repo"
2120
user_model "code.gitea.io/gitea/models/user"
@@ -593,12 +592,12 @@ func runCreateUser(c *cli.Context) error {
593592
}
594593

595594
if c.Bool("access-token") {
596-
t := &models.AccessToken{
595+
t := &auth_model.AccessToken{
597596
Name: "gitea-admin",
598597
UID: u.ID,
599598
}
600599

601-
if err := models.NewAccessToken(t); err != nil {
600+
if err := auth_model.NewAccessToken(t); err != nil {
602601
return err
603602
}
604603

@@ -700,12 +699,12 @@ func runGenerateAccessToken(c *cli.Context) error {
700699
return err
701700
}
702701

703-
t := &models.AccessToken{
702+
t := &auth_model.AccessToken{
704703
Name: c.String("token-name"),
705704
UID: user.ID,
706705
}
707706

708-
if err := models.NewAccessToken(t); err != nil {
707+
if err := auth_model.NewAccessToken(t); err != nil {
709708
return err
710709
}
711710

@@ -779,9 +778,9 @@ func runRepoSyncReleases(_ *cli.Context) error {
779778
}
780779

781780
func getReleaseCount(id int64) (int64, error) {
782-
return models.GetReleaseCountByRepoID(
781+
return repo_model.GetReleaseCountByRepoID(
783782
id,
784-
models.FindReleasesOptions{
783+
repo_model.FindReleasesOptions{
785784
IncludeTags: true,
786785
},
787786
)
@@ -844,8 +843,8 @@ func runAddOauth(c *cli.Context) error {
844843
return err
845844
}
846845

847-
return auth.CreateSource(&auth.Source{
848-
Type: auth.OAuth2,
846+
return auth_model.CreateSource(&auth_model.Source{
847+
Type: auth_model.OAuth2,
849848
Name: c.String("name"),
850849
IsActive: true,
851850
Cfg: parseOAuth2Config(c),
@@ -864,7 +863,7 @@ func runUpdateOauth(c *cli.Context) error {
864863
return err
865864
}
866865

867-
source, err := auth.GetSourceByID(c.Int64("id"))
866+
source, err := auth_model.GetSourceByID(c.Int64("id"))
868867
if err != nil {
869868
return err
870869
}
@@ -944,7 +943,7 @@ func runUpdateOauth(c *cli.Context) error {
944943
oAuth2Config.CustomURLMapping = customURLMapping
945944
source.Cfg = oAuth2Config
946945

947-
return auth.UpdateSource(source)
946+
return auth_model.UpdateSource(source)
948947
}
949948

950949
func parseSMTPConfig(c *cli.Context, conf *smtp.Source) error {
@@ -1015,8 +1014,8 @@ func runAddSMTP(c *cli.Context) error {
10151014
smtpConfig.Auth = "PLAIN"
10161015
}
10171016

1018-
return auth.CreateSource(&auth.Source{
1019-
Type: auth.SMTP,
1017+
return auth_model.CreateSource(&auth_model.Source{
1018+
Type: auth_model.SMTP,
10201019
Name: c.String("name"),
10211020
IsActive: active,
10221021
Cfg: &smtpConfig,
@@ -1035,7 +1034,7 @@ func runUpdateSMTP(c *cli.Context) error {
10351034
return err
10361035
}
10371036

1038-
source, err := auth.GetSourceByID(c.Int64("id"))
1037+
source, err := auth_model.GetSourceByID(c.Int64("id"))
10391038
if err != nil {
10401039
return err
10411040
}
@@ -1056,7 +1055,7 @@ func runUpdateSMTP(c *cli.Context) error {
10561055

10571056
source.Cfg = smtpConfig
10581057

1059-
return auth.UpdateSource(source)
1058+
return auth_model.UpdateSource(source)
10601059
}
10611060

10621061
func runListAuth(c *cli.Context) error {
@@ -1067,7 +1066,7 @@ func runListAuth(c *cli.Context) error {
10671066
return err
10681067
}
10691068

1070-
authSources, err := auth.Sources()
1069+
authSources, err := auth_model.Sources()
10711070
if err != nil {
10721071
return err
10731072
}
@@ -1105,7 +1104,7 @@ func runDeleteAuth(c *cli.Context) error {
11051104
return err
11061105
}
11071106

1108-
source, err := auth.GetSourceByID(c.Int64("id"))
1107+
source, err := auth_model.GetSourceByID(c.Int64("id"))
11091108
if err != nil {
11101109
return err
11111110
}

cmd/doctor.go

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package cmd
66

77
import (
8+
"errors"
89
"fmt"
910
golog "log"
1011
"os"
@@ -123,32 +124,62 @@ func runRecreateTable(ctx *cli.Context) error {
123124
})
124125
}
125126

126-
func runDoctor(ctx *cli.Context) error {
127-
stdCtx, cancel := installSignals()
128-
defer cancel()
129-
130-
// Silence the default loggers
131-
log.DelNamedLogger("console")
132-
log.DelNamedLogger(log.DEFAULT)
133-
134-
// Now setup our own
127+
func setDoctorLogger(ctx *cli.Context) {
135128
logFile := ctx.String("log-file")
136129
if !ctx.IsSet("log-file") {
137130
logFile = "doctor.log"
138131
}
139-
140132
colorize := log.CanColorStdout
141133
if ctx.IsSet("color") {
142134
colorize = ctx.Bool("color")
143135
}
144136

145137
if len(logFile) == 0 {
146138
log.NewLogger(1000, "doctor", "console", fmt.Sprintf(`{"level":"NONE","stacktracelevel":"NONE","colorize":%t}`, colorize))
147-
} else if logFile == "-" {
139+
return
140+
}
141+
142+
defer func() {
143+
recovered := recover()
144+
if recovered == nil {
145+
return
146+
}
147+
148+
err, ok := recovered.(error)
149+
if !ok {
150+
panic(recovered)
151+
}
152+
if errors.Is(err, os.ErrPermission) {
153+
fmt.Fprintf(os.Stderr, "ERROR: Unable to write logs to provided file due to permissions error: %s\n %v\n", logFile, err)
154+
} else {
155+
fmt.Fprintf(os.Stderr, "ERROR: Unable to write logs to provided file: %s\n %v\n", logFile, err)
156+
}
157+
fmt.Fprintf(os.Stderr, "WARN: Logging will be disabled\n Use `--log-file` to configure log file location\n")
158+
log.NewLogger(1000, "doctor", "console", fmt.Sprintf(`{"level":"NONE","stacktracelevel":"NONE","colorize":%t}`, colorize))
159+
}()
160+
161+
if logFile == "-" {
148162
log.NewLogger(1000, "doctor", "console", fmt.Sprintf(`{"level":"trace","stacktracelevel":"NONE","colorize":%t}`, colorize))
149163
} else {
150164
log.NewLogger(1000, "doctor", "file", fmt.Sprintf(`{"filename":%q,"level":"trace","stacktracelevel":"NONE"}`, logFile))
151165
}
166+
}
167+
168+
func runDoctor(ctx *cli.Context) error {
169+
stdCtx, cancel := installSignals()
170+
defer cancel()
171+
172+
// Silence the default loggers
173+
log.DelNamedLogger("console")
174+
log.DelNamedLogger(log.DEFAULT)
175+
176+
// Now setup our own
177+
setDoctorLogger(ctx)
178+
179+
colorize := log.CanColorStdout
180+
if ctx.IsSet("color") {
181+
colorize = ctx.Bool("color")
182+
}
152183

153184
// Finally redirect the default golog to here
154185
golog.SetFlags(0)

cmd/embedded.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func initEmbeddedExtractor(c *cli.Context) error {
123123

124124
sections["public"] = &section{Path: "public", Names: public.AssetNames, IsDir: public.AssetIsDir, Asset: public.Asset}
125125
sections["options"] = &section{Path: "options", Names: options.AssetNames, IsDir: options.AssetIsDir, Asset: options.Asset}
126-
sections["templates"] = &section{Path: "templates", Names: templates.AssetNames, IsDir: templates.AssetIsDir, Asset: templates.Asset}
126+
sections["templates"] = &section{Path: "templates", Names: templates.BuiltinAssetNames, IsDir: templates.BuiltinAssetIsDir, Asset: templates.BuiltinAsset}
127127

128128
for _, sec := range sections {
129129
assets = append(assets, buildAssetList(sec, pats, c)...)

cmd/migrate_storage.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,8 @@ func migrateRepoAvatars(ctx context.Context, dstStorage storage.ObjectStorage) e
112112

113113
func migrateRepoArchivers(ctx context.Context, dstStorage storage.ObjectStorage) error {
114114
return db.IterateObjects(ctx, func(archiver *repo_model.RepoArchiver) error {
115-
p, err := archiver.RelativePath()
116-
if err != nil {
117-
return err
118-
}
119-
_, err = storage.Copy(dstStorage, p, storage.RepoArchives, p)
115+
p := archiver.RelativePath()
116+
_, err := storage.Copy(dstStorage, p, storage.RepoArchives, p)
120117
return err
121118
})
122119
}

0 commit comments

Comments
 (0)