Skip to content

Commit ed4bb80

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Add API to serve blob or LFS file content (go-gitea#19689) Disable unnecessary mirroring elements (go-gitea#18527) [skip ci] Updated translations via Crowdin Remove customized (unmaintained) dropdown, improve aria a11y for dropdown (go-gitea#19861) Set Setpgid on child git processes (go-gitea#19865)
2 parents 47430a5 + df9612b commit ed4bb80

File tree

30 files changed

+509
-4471
lines changed

30 files changed

+509
-4471
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@ fomantic:
703703
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
704704
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
705705
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
706-
cp -f web_src/js/vendor/dropdown.js $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/definitions/modules
707706
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
708707
rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*
709708

cmd/serv.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"code.gitea.io/gitea/modules/log"
2525
"code.gitea.io/gitea/modules/pprof"
2626
"code.gitea.io/gitea/modules/private"
27+
"code.gitea.io/gitea/modules/process"
2728
repo_module "code.gitea.io/gitea/modules/repository"
2829
"code.gitea.io/gitea/modules/setting"
2930
"code.gitea.io/gitea/services/lfs"
@@ -306,6 +307,7 @@ func runServ(c *cli.Context) error {
306307
}
307308
}
308309

310+
process.SetSysProcAttribute(gitcmd)
309311
gitcmd.Dir = setting.RepoRootPath
310312
gitcmd.Stdout = os.Stdout
311313
gitcmd.Stdin = os.Stdin

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ PATH =
20912091
;[mirror]
20922092
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20932093
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2094-
;; Enables the mirror functionality. Set to **false** to disable all mirrors.
2094+
;; Enables the mirror functionality. Set to **false** to disable all mirrors. Pre-existing mirrors remain valid but won't be updated; may be converted to regular repo.
20952095
;ENABLED = true
20962096
;; Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
20972097
;DISABLE_NEW_PULL = false

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
10951095

10961096
## Mirror (`mirror`)
10971097

1098-
- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors.
1098+
- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors. Pre-existing mirrors remain valid but won't be updated; may be converted to regular repo.
10991099
- `DISABLE_NEW_PULL`: **false**: Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
11001100
- `DISABLE_NEW_PUSH`: **false**: Disable the creation of **new** push mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
11011101
- `DEFAULT_INTERVAL`: **8h**: Default interval between each check
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package integrations
6+
7+
import (
8+
"net/http"
9+
"net/url"
10+
"os"
11+
"testing"
12+
13+
api "code.gitea.io/gitea/modules/structs"
14+
"code.gitea.io/gitea/modules/util"
15+
16+
"github.com/stretchr/testify/assert"
17+
)
18+
19+
func TestAPIGetRawFileOrLFS(t *testing.T) {
20+
defer prepareTestEnv(t)()
21+
22+
// Test with raw file
23+
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1/media/README.md")
24+
resp := MakeRequest(t, req, http.StatusOK)
25+
assert.Equal(t, "# repo1\n\nDescription for repo1", resp.Body.String())
26+
27+
// Test with LFS
28+
onGiteaRun(t, func(t *testing.T, u *url.URL) {
29+
httpContext := NewAPITestContext(t, "user2", "repo-lfs-test")
30+
doAPICreateRepository(httpContext, false, func(t *testing.T, repository api.Repository) {
31+
u.Path = httpContext.GitPath()
32+
dstPath, err := os.MkdirTemp("", httpContext.Reponame)
33+
assert.NoError(t, err)
34+
defer util.RemoveAll(dstPath)
35+
36+
u.Path = httpContext.GitPath()
37+
u.User = url.UserPassword("user2", userPassword)
38+
39+
t.Run("Clone", doGitClone(dstPath, u))
40+
41+
dstPath2, err := os.MkdirTemp("", httpContext.Reponame)
42+
assert.NoError(t, err)
43+
defer util.RemoveAll(dstPath2)
44+
45+
t.Run("Partial Clone", doPartialGitClone(dstPath2, u))
46+
47+
lfs, _ := lfsCommitAndPushTest(t, dstPath)
48+
49+
reqLFS := NewRequest(t, "GET", "/api/v1/repos/user2/repo1/media/"+lfs)
50+
respLFS := MakeRequestNilResponseRecorder(t, reqLFS, http.StatusOK)
51+
assert.Equal(t, littleSize, respLFS.Length)
52+
53+
doAPIDeleteRepository(httpContext)
54+
})
55+
})
56+
}

modules/git/blame.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func createBlameReader(ctx context.Context, dir string, command ...string) (*Bla
124124
cmd := exec.CommandContext(ctx, command[0], command[1:]...)
125125
cmd.Dir = dir
126126
cmd.Stderr = os.Stderr
127+
process.SetSysProcAttribute(cmd)
127128

128129
stdout, err := cmd.StdoutPipe()
129130
if err != nil {

modules/git/command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func (c *Command) Run(opts *RunOpts) error {
157157
"GIT_NO_REPLACE_OBJECTS=1",
158158
)
159159

160+
process.SetSysProcAttribute(cmd)
160161
cmd.Dir = opts.Dir
161162
cmd.Stdout = opts.Stdout
162163
cmd.Stderr = opts.Stderr

modules/markup/external/external.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
124124
cmd.Stdin = input
125125
}
126126
cmd.Stdout = output
127+
process.SetSysProcAttribute(cmd)
128+
127129
if err := cmd.Run(); err != nil {
128130
return fmt.Errorf("%s render run command %s %v failed: %v", p.Name(), commands[0], args, err)
129131
}

modules/process/manager_exec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (pm *Manager) ExecDirEnvStdIn(ctx context.Context, timeout time.Duration, d
5858
if stdIn != nil {
5959
cmd.Stdin = stdIn
6060
}
61+
SetSysProcAttribute(cmd)
6162

6263
if err := cmd.Start(); err != nil {
6364
return "", "", err

modules/process/manager_unix.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !windows
6+
7+
package process
8+
9+
import (
10+
"os/exec"
11+
"syscall"
12+
)
13+
14+
// SetSysProcAttribute sets the common SysProcAttrs for commands
15+
func SetSysProcAttribute(cmd *exec.Cmd) {
16+
// When Gitea runs SubProcessA -> SubProcessB and SubProcessA gets killed by context timeout, use setpgid to make sure the sub processes can be reaped instead of leaving defunct(zombie) processes.
17+
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
18+
}

0 commit comments

Comments
 (0)