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+
}

modules/process/manager_windows.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
)
12+
13+
// SetSysProcAttribute sets the common SysProcAttrs for commands
14+
func SetSysProcAttribute(cmd *exec.Cmd) {
15+
// Do nothing
16+
}

modules/ssh/ssh.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ func sessionHandler(session ssh.Session) {
102102
}
103103
defer stdin.Close()
104104

105+
process.SetSysProcAttribute(cmd)
106+
105107
wg := &sync.WaitGroup{}
106108
wg.Add(2)
107109

options/locale/locale_en-US.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,6 @@ need_auth = Authorization
930930
migrate_options = Migration Options
931931
migrate_service = Migration Service
932932
migrate_options_mirror_helper = This repository will be a <span class="text blue">mirror</span>
933-
migrate_options_mirror_disabled = Your site administrator has disabled new mirrors.
934933
migrate_options_lfs = Migrate LFS files
935934
migrate_options_lfs_endpoint.label = LFS Endpoint
936935
migrate_options_lfs_endpoint.description = Migration will attempt to use your Git remote to <a target="_blank" rel="noopener noreferrer" href="%s">determine the LFS server</a>. You can also specify a custom endpoint if the repository LFS data is stored somewhere else.

options/locale/locale_zh-TW.ini

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ error404=您正嘗試訪問的頁面 <strong>不存在</strong> 或 <strong>您
105105

106106
never=從來沒有
107107

108+
rss_feed=RSS 摘要
108109

109110
[error]
110111
occurred=發生錯誤
@@ -496,7 +497,7 @@ target_branch_not_exist=目標分支不存在
496497
[user]
497498
change_avatar=更改大頭貼...
498499
join_on=加入於
499-
repositories=儲存庫列表
500+
repositories=儲存庫
500501
activity=公開動態
501502
followers=追蹤者
502503
starred=已加星號
@@ -775,6 +776,7 @@ webauthn_delete_key_desc=如果您移除安全金鑰,將不能再使用它登
775776
manage_account_links=管理已連結的帳戶
776777
manage_account_links_desc=這些外部帳戶已連結到您的 Gitea 帳戶。
777778
account_links_not_available=目前沒有連結到您的 Gitea 帳戶的外部帳戶
779+
link_account=連結帳戶
778780
remove_account_link=刪除已連結的帳戶
779781
remove_account_link_desc=刪除連結帳戶將撤銷其對 Gitea 帳戶的存取權限。是否繼續?
780782
remove_account_link_success=已移除連結的帳戶。
@@ -1038,6 +1040,7 @@ line_unicode=`這一行有隱藏的 Unicode 字元`
10381040
escape_control_characters=Escape
10391041
unescape_control_characters=Unescape
10401042
file_copy_permalink=複製固定連結
1043+
view_git_blame=檢視 Git Blame
10411044
video_not_supported_in_browser=您的瀏覽器不支援使用 HTML5 播放影片。
10421045
audio_not_supported_in_browser=您的瀏覽器不支援 HTML5 的「audio」標籤
10431046
stored_lfs=已使用 Git LFS 儲存
@@ -1458,6 +1461,7 @@ issues.review.add_review_request=請求了 %s 來審核 %s
14581461
issues.review.remove_review_request=移除了對 %s 的審核請求 %s
14591462
issues.review.remove_review_request_self=拒絕了審核 %s
14601463
issues.review.pending=待處理
1464+
issues.review.pending.tooltip=目前其他使用者還不能看見此留言。要送出您待定的留言請在頁面最上方選擇「%s」->「%s/%s/%s」。
14611465
issues.review.review=審核
14621466
issues.review.reviewers=審核者
14631467
issues.review.outdated=過時的
@@ -1476,6 +1480,7 @@ issues.content_history.created=建立
14761480
issues.content_history.delete_from_history=刪除歷程記錄
14771481
issues.content_history.delete_from_history_confirm=刪除歷程記錄?
14781482
issues.content_history.options=選項
1483+
issues.reference_link=參考: %s
14791484

14801485
compare.compare_base=基底分支
14811486
compare.compare_head=比較
@@ -1484,6 +1489,9 @@ pulls.desc=啟用合併請求和程式碼審核。
14841489
pulls.new=建立合併請求
14851490
pulls.view=檢視合併請求
14861491
pulls.compare_changes=建立合併請求
1492+
pulls.allow_edits_from_maintainers=允許維護者編輯
1493+
pulls.allow_edits_from_maintainers_desc=對基礎分支有寫入權限的使用者也可以推送到此分支
1494+
pulls.allow_edits_from_maintainers_err=更新失敗
14871495
pulls.compare_changes_desc=選擇合併的目標分支和來源分支。
14881496
pulls.compare_base=合併到
14891497
pulls.compare_compare=拉取自
@@ -2391,6 +2399,7 @@ dashboard.new_version_hint=現已推出 Gitea %s,您正在執行 %s。查看<a
23912399
dashboard.statistic=摘要
23922400
dashboard.operations=維護作業
23932401
dashboard.system_status=系統狀態
2402+
dashboard.statistic_info=Gitea 資料庫統計: <b>%d</b> 位使用者,<b>%d</b> 個組織,<b>%d</b> 個公鑰,<b>%d</b> 個儲存庫,<b>%d</b> 個儲存庫關注,<b>%d</b> 個星號,~<b>%d</b> 次行為,<b>%d</b> 條權限記錄,<b>%d</b> 個問題,<b>%d</b> 則留言,<b>%d</b> 個社群帳戶,<b>%d</b> 個使用者關注,<b>%d</b> 個鏡像,<b>%d</b> 個版本發佈,<b>%d</b> 個認證來源,<b>%d</b> 個 Webhook ,<b>%d</b> 個里程碑,<b>%d</b> 個標籤,<b>%d</b> 個 Hook 任務,<b>%d</b> 個團隊,<b>%d</b> 個更新任務,<b>%d</b> 個附件。
23942403
dashboard.operation_name=作業名稱
23952404
dashboard.operation_switch=開關
23962405
dashboard.operation_run=執行
@@ -2496,6 +2505,7 @@ users.allow_import_local=可以匯入本地儲存庫
24962505
users.allow_create_organization=可以建立組織
24972506
users.update_profile=更新使用者帳戶
24982507
users.delete_account=刪除使用者帳戶
2508+
users.cannot_delete_self=您無法刪除您自己
24992509
users.still_own_repo=這個使用者還擁有一個或更多的儲存庫。請先刪除或是轉移這些儲存庫。
25002510
users.still_has_org=此使用者是組織的成員。請先將他從組織中移除。
25012511
users.deletion_success=使用者帳戶已被刪除。
@@ -2812,6 +2822,8 @@ monitor.next=下次執行時間
28122822
monitor.previous=上次執行時間
28132823
monitor.execute_times=執行次數
28142824
monitor.process=執行中的處理程序
2825+
monitor.stacktrace=堆疊追蹤
2826+
monitor.goroutines=%d 個 Goroutines
28152827
monitor.desc=描述
28162828
monitor.start=開始時間
28172829
monitor.execute_time=已執行時間

routers/api/v1/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ func Routes() *web.Route {
826826
Delete(reqAdmin(), repo.DeleteTeam)
827827
}, reqToken())
828828
m.Get("/raw/*", context.ReferencesGitRepo(), context.RepoRefForAPI, reqRepoReader(unit.TypeCode), repo.GetRawFile)
829+
m.Get("/media/*", context.ReferencesGitRepo(), context.RepoRefForAPI, reqRepoReader(unit.TypeCode), repo.GetRawFileOrLFS)
829830
m.Get("/archive/*", reqRepoReader(unit.TypeCode), repo.GetArchive)
830831
m.Combo("/forks").Get(repo.ListForks).
831832
Post(reqToken(), reqRepoReader(unit.TypeCode), bind(api.CreateForkOption{}), repo.CreateFork)

0 commit comments

Comments
 (0)