Skip to content

Commit abee597

Browse files
author
zjj
committed
* 'main' of https://github.com/go-gitea/gitea: Add packagist webhook (go-gitea#18224) Fix mime-type detection for HTTP server (go-gitea#18370) Always use git command but not os.Command (go-gitea#18363) Add deprecated for LFS_CONTENT_PATH on zh-cn docs (go-gitea#18362) [skip ci] Updated translations via Crowdin Make gitea, gitea-vet future-proof (go-gitea#18361) Pause queues (go-gitea#15928) Disable content sniffing on `PlainTextBytes` (go-gitea#18359) Update github.com/duo-labs/webauthn (go-gitea#18357)
2 parents d3dbab0 + 3349fd8 commit abee597

Some content is hidden

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

67 files changed

+1964
-234
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ For imports you should use the following format (_without_ the comments)
141141
```go
142142
import (
143143
// stdlib
144-
"encoding/json"
145144
"fmt"
145+
"math"
146146

147147
// local packages
148148
"code.gitea.io/gitea/models"

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ menu:
8080

8181
- `LFS_START_SERVER`: 是否启用 git-lfs 支持. 可以为 `true``false`, 默认是 `false`
8282
- `LFS_JWT_SECRET`: LFS 认证密钥,改成自己的。
83-
- `LFS_CONTENT_PATH`: **已废弃**, 存放 lfs 命令上传的文件的地方,默认是 `data/lfs`
83+
- `LFS_CONTENT_PATH`: **已废弃**, 存放 lfs 命令上传的文件的地方,默认是 `data/lfs`**废弃** 请使用 `[lfs]` 的设置。
8484

8585
## Database (`database`)
8686

docs/content/doc/features/webhooks.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ All event pushes are POST requests. The methods currently supported are:
2828
- Microsoft Teams
2929
- Feishu
3030
- Wechatwork
31+
- Packagist
3132

3233
### Event information
3334

docs/content/doc/features/webhooks.zh-cn.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ Gitea 的存储 webhook。这可以有存储库管路设定页 `/:username/:repo
2727
- Microsoft Teams
2828
- Feishu
2929
- Wechatwork
30+
- Packagist
3031

3132
## TBD

docs/content/doc/features/webhooks.zh-tw.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Gitea 的儲存庫事件支援 web hook。這可以有儲存庫管理員在設
2727
- Microsoft Teams
2828
- Feishu
2929
- Wechatwork
30+
- Packagist
3031

3132
### 事件資訊
3233

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
github.com/denisenkom/go-mssqldb v0.10.0
3131
github.com/djherbis/buffer v1.2.0
3232
github.com/djherbis/nio/v3 v3.0.1
33-
github.com/duo-labs/webauthn v0.0.0-20211221191814-a22482edaa3b
33+
github.com/duo-labs/webauthn v0.0.0-20220122034320-81aea484c951
3434
github.com/dustin/go-humanize v1.0.0
3535
github.com/editorconfig/editorconfig-core-go/v2 v2.4.2
3636
github.com/emirpasic/gods v1.12.0
@@ -54,7 +54,7 @@ require (
5454
github.com/golang-jwt/jwt/v4 v4.2.0
5555
github.com/golang/snappy v0.0.4 // indirect
5656
github.com/google/go-github/v39 v39.2.0
57-
github.com/google/uuid v1.2.0
57+
github.com/google/uuid v1.3.0
5858
github.com/gorilla/feeds v1.1.1
5959
github.com/gorilla/mux v1.8.0 // indirect
6060
github.com/gorilla/sessions v1.2.1
@@ -145,8 +145,6 @@ replace github.com/markbates/goth v1.68.0 => github.com/zeripath/goth v1.68.1-0.
145145

146146
replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142115-2c99e1ffdfa0
147147

148-
replace github.com/duo-labs/webauthn => github.com/authelia/webauthn v0.0.0-20211225121951-80d1f2a572e4
149-
150148
replace github.com/satori/go.uuid v1.2.0 => github.com/gofrs/uuid v4.2.0+incompatible
151149

152150
exclude github.com/gofrs/uuid v3.2.0+incompatible

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535/go.mod h1:o
131131
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
132132
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
133133
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
134-
github.com/authelia/webauthn v0.0.0-20211225121951-80d1f2a572e4 h1:u3eFvgr4A8IjlAokbFt6XY6VdurX7DEYnQMQ4K2yobc=
135-
github.com/authelia/webauthn v0.0.0-20211225121951-80d1f2a572e4/go.mod h1:EYSpSkwoEcryMmQGfhol2IiB3IMN9IIIaNd/wcAQMGQ=
136134
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
137135
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
138136
github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
@@ -276,6 +274,8 @@ github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD
276274
github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
277275
github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
278276
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
277+
github.com/duo-labs/webauthn v0.0.0-20220122034320-81aea484c951 h1:17esZ09oW+29rklBtCVphIguql2u3NxYH2OasFPPZoo=
278+
github.com/duo-labs/webauthn v0.0.0-20220122034320-81aea484c951/go.mod h1:nHy3JdztZWcsjenDeBuE8gn171OAwg12LBN027UP5AE=
279279
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
280280
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
281281
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
@@ -491,7 +491,6 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
491491
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
492492
github.com/goccy/go-json v0.7.4 h1:B44qRUFwz/vxPKPISQ1KhvzRi9kZ28RAf6YtjriBZ5k=
493493
github.com/goccy/go-json v0.7.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
494-
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
495494
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
496495
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
497496
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@@ -585,8 +584,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
585584
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
586585
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
587586
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
588-
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
589-
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
587+
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
588+
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
590589
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
591590
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
592591
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=

models/webhook/webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ const (
161161
FEISHU HookType = "feishu"
162162
MATRIX HookType = "matrix"
163163
WECHATWORK HookType = "wechatwork"
164+
PACKAGIST HookType = "packagist"
164165
)
165166

166167
// HookStatus is the status of a web hook

modules/context/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ func (ctx *Context) PlainTextBytes(status int, bs []byte) {
292292
}
293293
ctx.Resp.WriteHeader(status)
294294
ctx.Resp.Header().Set("Content-Type", "text/plain;charset=utf-8")
295+
ctx.Resp.Header().Set("X-Content-Type-Options", "nosniff")
295296
if _, err := ctx.Resp.Write(bs); err != nil {
296297
log.Error("Write bytes failed: %v", err)
297298
}

modules/git/diff.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ import (
1111
"fmt"
1212
"io"
1313
"os"
14-
"os/exec"
1514
"regexp"
1615
"strconv"
1716
"strings"
1817

1918
"code.gitea.io/gitea/modules/log"
20-
"code.gitea.io/gitea/modules/process"
2119
)
2220

2321
// RawDiffType type of a raw diff.
@@ -55,43 +53,41 @@ func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diff
5553
if len(file) > 0 {
5654
fileArgs = append(fileArgs, "--", file)
5755
}
58-
// FIXME: graceful: These commands should have a timeout
59-
ctx, _, finished := process.GetManager().AddContext(repo.Ctx, fmt.Sprintf("GetRawDiffForFile: [repo_path: %s]", repo.Path))
60-
defer finished()
6156

62-
var cmd *exec.Cmd
57+
var args []string
6358
switch diffType {
6459
case RawDiffNormal:
6560
if len(startCommit) != 0 {
66-
cmd = exec.CommandContext(ctx, GitExecutable, append([]string{"diff", "-M", startCommit, endCommit}, fileArgs...)...)
61+
args = append([]string{"diff", "-M", startCommit, endCommit}, fileArgs...)
6762
} else if commit.ParentCount() == 0 {
68-
cmd = exec.CommandContext(ctx, GitExecutable, append([]string{"show", endCommit}, fileArgs...)...)
63+
args = append([]string{"show", endCommit}, fileArgs...)
6964
} else {
7065
c, _ := commit.Parent(0)
71-
cmd = exec.CommandContext(ctx, GitExecutable, append([]string{"diff", "-M", c.ID.String(), endCommit}, fileArgs...)...)
66+
args = append([]string{"diff", "-M", c.ID.String(), endCommit}, fileArgs...)
7267
}
7368
case RawDiffPatch:
7469
if len(startCommit) != 0 {
7570
query := fmt.Sprintf("%s...%s", endCommit, startCommit)
76-
cmd = exec.CommandContext(ctx, GitExecutable, append([]string{"format-patch", "--no-signature", "--stdout", "--root", query}, fileArgs...)...)
71+
args = append([]string{"format-patch", "--no-signature", "--stdout", "--root", query}, fileArgs...)
7772
} else if commit.ParentCount() == 0 {
78-
cmd = exec.CommandContext(ctx, GitExecutable, append([]string{"format-patch", "--no-signature", "--stdout", "--root", endCommit}, fileArgs...)...)
73+
args = append([]string{"format-patch", "--no-signature", "--stdout", "--root", endCommit}, fileArgs...)
7974
} else {
8075
c, _ := commit.Parent(0)
8176
query := fmt.Sprintf("%s...%s", endCommit, c.ID.String())
82-
cmd = exec.CommandContext(ctx, GitExecutable, append([]string{"format-patch", "--no-signature", "--stdout", query}, fileArgs...)...)
77+
args = append([]string{"format-patch", "--no-signature", "--stdout", query}, fileArgs...)
8378
}
8479
default:
8580
return fmt.Errorf("invalid diffType: %s", diffType)
8681
}
8782

8883
stderr := new(bytes.Buffer)
89-
90-
cmd.Dir = repo.Path
91-
cmd.Stdout = writer
92-
cmd.Stderr = stderr
93-
94-
if err = cmd.Run(); err != nil {
84+
cmd := NewCommandContextNoGlobals(repo.Ctx, args...)
85+
if err = cmd.RunWithContext(&RunContext{
86+
Timeout: -1,
87+
Dir: repo.Path,
88+
Stdout: writer,
89+
Stderr: stderr,
90+
}); err != nil {
9591
return fmt.Errorf("Run: %v - %s", err, stderr)
9692
}
9793
return nil

0 commit comments

Comments
 (0)