Skip to content

Commit da5fb5c

Browse files
authored
Merge branch 'main' into lunny/merge_tree_conflict_check
2 parents 0d28912 + a7eceb5 commit da5fb5c

File tree

39 files changed

+350
-348
lines changed

39 files changed

+350
-348
lines changed

.github/workflows/pull-labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
contents: read
1616
pull-requests: write
1717
steps:
18-
- uses: actions/labeler@v5
18+
- uses: actions/labeler@v6
1919
with:
2020
sync-labels: true

go.mod

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module code.gitea.io/gitea
22

3-
go 1.25.1
3+
go 1.25.3
44

55
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
66
// But some CAs use negative serial number, just relax the check. related:
@@ -35,7 +35,7 @@ require (
3535
github.com/bohde/codel v0.2.0
3636
github.com/buildkite/terminal-to-html/v3 v3.16.8
3737
github.com/caddyserver/certmagic v0.24.0
38-
github.com/charmbracelet/git-lfs-transfer v0.2.0
38+
github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20251013092601-6327009efd21
3939
github.com/chi-middleware/proxy v1.1.1
4040
github.com/dimiro1/reply v0.0.0-20200315094148-d0136a4c9e21
4141
github.com/djherbis/buffer v1.2.0
@@ -56,7 +56,7 @@ require (
5656
github.com/go-co-op/gocron v1.37.0
5757
github.com/go-enry/go-enry/v2 v2.9.2
5858
github.com/go-git/go-billy/v5 v5.6.2
59-
github.com/go-git/go-git/v5 v5.16.2
59+
github.com/go-git/go-git/v5 v5.16.3
6060
github.com/go-ldap/ldap/v3 v3.4.11
6161
github.com/go-redsync/redsync/v4 v4.13.0
6262
github.com/go-sql-driver/mysql v1.9.3
@@ -121,7 +121,7 @@ require (
121121
golang.org/x/net v0.44.0
122122
golang.org/x/oauth2 v0.30.0
123123
golang.org/x/sync v0.17.0
124-
golang.org/x/sys v0.36.0
124+
golang.org/x/sys v0.37.0
125125
golang.org/x/text v0.30.0
126126
google.golang.org/grpc v1.75.0
127127
google.golang.org/protobuf v1.36.8
@@ -298,9 +298,6 @@ replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
298298

299299
replace github.com/nektos/act => gitea.com/gitea/act v0.261.7-0.20251003180512-ac6e4b751763
300300

301-
// TODO: the only difference is in `PutObject`: the fork doesn't use `NewVerifyingReader(r, sha256.New(), oid, expectedSize)`, need to figure out why
302-
replace github.com/charmbracelet/git-lfs-transfer => gitea.com/gitea/git-lfs-transfer v0.2.0
303-
304301
replace git.sr.ht/~mariusor/go-xsd-duration => gitea.com/gitea/go-xsd-duration v0.0.0-20220703122237-02e73435a078
305302

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

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
3333
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
3434
gitea.com/gitea/act v0.261.7-0.20251003180512-ac6e4b751763 h1:ohdxegvslDEllZmRNDqpKun6L4Oq81jNdEDtGgHEV2c=
3535
gitea.com/gitea/act v0.261.7-0.20251003180512-ac6e4b751763/go.mod h1:Pg5C9kQY1CEA3QjthjhlrqOC/QOT5NyWNjOjRHw23Ok=
36-
gitea.com/gitea/git-lfs-transfer v0.2.0 h1:baHaNoBSRaeq/xKayEXwiDQtlIjps4Ac/Ll4KqLMB40=
37-
gitea.com/gitea/git-lfs-transfer v0.2.0/go.mod h1:UrXUCm3xLQkq15fu7qlXHUMlrhdlXHoi13KH2Dfiits=
3836
gitea.com/gitea/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:BAFmdZpRW7zMQZQDClaCWobRj9uL1MR3MzpCVJvc5s4=
3937
gitea.com/gitea/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
4038
gitea.com/go-chi/binding v0.0.0-20240430071103-39a851e106ed h1:EZZBtilMLSZNWtHHcgq2mt6NSGhJSZBuduAlinMEmso=
@@ -219,6 +217,8 @@ github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a h1:MISbI8sU/PSK/
219217
github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a/go.mod h1:2GxOXOlEPAMFPfp014mK1SWq8G8BN8o7/dfYqJrVGn8=
220218
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
221219
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
220+
github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20251013092601-6327009efd21 h1:2d64+4Jek9vjYwhY93AjbleiVH+AeWvPwPmDi1mfKFQ=
221+
github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20251013092601-6327009efd21/go.mod h1:fNlYtCHWTRC8MofQERZkVUNUWaOvZeTBqHn/amSbKZI=
222222
github.com/chi-middleware/proxy v1.1.1 h1:4HaXUp8o2+bhHr1OhVy+VjN0+L7/07JDcn6v7YrTjrQ=
223223
github.com/chi-middleware/proxy v1.1.1/go.mod h1:jQwMEJct2tz9VmtCELxvnXoMfa+SOdikvbVJVHv/M+0=
224224
github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
@@ -339,8 +339,8 @@ github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UN
339339
github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
340340
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
341341
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
342-
github.com/go-git/go-git/v5 v5.16.2 h1:fT6ZIOjE5iEnkzKyxTHK1W4HGAsPhqEqiSAssSO77hM=
343-
github.com/go-git/go-git/v5 v5.16.2/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
342+
github.com/go-git/go-git/v5 v5.16.3 h1:Z8BtvxZ09bYm/yYNgPKCzgWtaRqDTgIKRgIRHBfU6Z8=
343+
github.com/go-git/go-git/v5 v5.16.3/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
344344
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
345345
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
346346
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
@@ -975,8 +975,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
975975
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
976976
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
977977
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
978-
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
979-
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
978+
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
979+
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
980980
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
981981
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
982982
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=

models/repo/repo.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,6 @@ func RelativePath(ownerName, repoName string) string {
229229
return strings.ToLower(ownerName) + "/" + strings.ToLower(repoName) + ".git"
230230
}
231231

232-
func RelativeWikiPath(ownerName, repoName string) string {
233-
return strings.ToLower(ownerName) + "/" + strings.ToLower(repoName) + ".wiki.git"
234-
}
235-
236232
// RelativePath should be an unix style path like username/reponame.git
237233
func (repo *Repository) RelativePath() string {
238234
return RelativePath(repo.OwnerName, repo.Name)
@@ -245,12 +241,6 @@ func (sr StorageRepo) RelativePath() string {
245241
return string(sr)
246242
}
247243

248-
// WikiStorageRepo returns the storage repo for the wiki
249-
// The wiki repository should have the same object format as the code repository
250-
func (repo *Repository) WikiStorageRepo() StorageRepo {
251-
return StorageRepo(RelativeWikiPath(repo.OwnerName, repo.Name))
252-
}
253-
254244
// SanitizedOriginalURL returns a sanitized OriginalURL
255245
func (repo *Repository) SanitizedOriginalURL() string {
256246
if repo.OriginalURL == "" {

models/repo/wiki.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package repo
77
import (
88
"context"
99
"fmt"
10-
"path/filepath"
1110
"strings"
1211

1312
user_model "code.gitea.io/gitea/models/user"
@@ -76,12 +75,12 @@ func (repo *Repository) WikiCloneLink(ctx context.Context, doer *user_model.User
7675
return repo.cloneLink(ctx, doer, repo.Name+".wiki")
7776
}
7877

79-
// WikiPath returns wiki data path by given user and repository name.
80-
func WikiPath(userName, repoName string) string {
81-
return filepath.Join(user_model.UserPath(userName), strings.ToLower(repoName)+".wiki.git")
78+
func RelativeWikiPath(ownerName, repoName string) string {
79+
return strings.ToLower(ownerName) + "/" + strings.ToLower(repoName) + ".wiki.git"
8280
}
8381

84-
// WikiPath returns wiki data path for given repository.
85-
func (repo *Repository) WikiPath() string {
86-
return WikiPath(repo.OwnerName, repo.Name)
82+
// WikiStorageRepo returns the storage repo for the wiki
83+
// The wiki repository should have the same object format as the code repository
84+
func (repo *Repository) WikiStorageRepo() StorageRepo {
85+
return StorageRepo(RelativeWikiPath(repo.OwnerName, repo.Name))
8786
}

models/repo/wiki_test.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
package repo_test
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
repo_model "code.gitea.io/gitea/models/repo"
1110
"code.gitea.io/gitea/models/unittest"
12-
"code.gitea.io/gitea/modules/setting"
1311

1412
"github.com/stretchr/testify/assert"
1513
)
@@ -23,15 +21,10 @@ func TestRepository_WikiCloneLink(t *testing.T) {
2321
assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS)
2422
}
2523

26-
func TestWikiPath(t *testing.T) {
24+
func TestRepository_RelativeWikiPath(t *testing.T) {
2725
assert.NoError(t, unittest.PrepareTestDatabase())
28-
expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
29-
assert.Equal(t, expected, repo_model.WikiPath("user2", "repo1"))
30-
}
3126

32-
func TestRepository_WikiPath(t *testing.T) {
33-
assert.NoError(t, unittest.PrepareTestDatabase())
3427
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
35-
expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
36-
assert.Equal(t, expected, repo.WikiPath())
28+
assert.Equal(t, "user2/repo1.wiki.git", repo_model.RelativeWikiPath(repo.OwnerName, repo.Name))
29+
assert.Equal(t, "user2/repo1.wiki.git", repo.WikiStorageRepo().RelativePath())
3730
}

modules/git/key.go

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33

44
package git
55

6-
import "code.gitea.io/gitea/modules/setting"
6+
import (
7+
"context"
8+
"strings"
9+
10+
"code.gitea.io/gitea/modules/git/gitcmd"
11+
"code.gitea.io/gitea/modules/setting"
12+
)
713

814
// Based on https://git-scm.com/docs/git-config#Documentation/git-config.txt-gpgformat
915
const (
@@ -24,3 +30,48 @@ func (s *SigningKey) String() string {
2430
setting.PanicInDevOrTesting("don't call SigningKey.String() - it exposes the KeyID which might be a local file path")
2531
return "SigningKey:" + s.Format
2632
}
33+
34+
// GetSigningKey returns the KeyID and git Signature for the repo
35+
func GetSigningKey(ctx context.Context, repoPath string) (*SigningKey, *Signature) {
36+
if setting.Repository.Signing.SigningKey == "none" {
37+
return nil, nil
38+
}
39+
40+
if setting.Repository.Signing.SigningKey == "default" || setting.Repository.Signing.SigningKey == "" {
41+
// Can ignore the error here as it means that commit.gpgsign is not set
42+
value, _, _ := gitcmd.NewCommand("config", "--get", "commit.gpgsign").WithDir(repoPath).RunStdString(ctx)
43+
sign, valid := ParseBool(strings.TrimSpace(value))
44+
if !sign || !valid {
45+
return nil, nil
46+
}
47+
48+
format, _, _ := gitcmd.NewCommand("config", "--default", SigningKeyFormatOpenPGP, "--get", "gpg.format").WithDir(repoPath).RunStdString(ctx)
49+
signingKey, _, _ := gitcmd.NewCommand("config", "--get", "user.signingkey").WithDir(repoPath).RunStdString(ctx)
50+
signingName, _, _ := gitcmd.NewCommand("config", "--get", "user.name").WithDir(repoPath).RunStdString(ctx)
51+
signingEmail, _, _ := gitcmd.NewCommand("config", "--get", "user.email").WithDir(repoPath).RunStdString(ctx)
52+
53+
if strings.TrimSpace(signingKey) == "" {
54+
return nil, nil
55+
}
56+
57+
return &SigningKey{
58+
KeyID: strings.TrimSpace(signingKey),
59+
Format: strings.TrimSpace(format),
60+
}, &Signature{
61+
Name: strings.TrimSpace(signingName),
62+
Email: strings.TrimSpace(signingEmail),
63+
}
64+
}
65+
66+
if setting.Repository.Signing.SigningKey == "" {
67+
return nil, nil
68+
}
69+
70+
return &SigningKey{
71+
KeyID: setting.Repository.Signing.SigningKey,
72+
Format: setting.Repository.Signing.SigningFormat,
73+
}, &Signature{
74+
Name: setting.Repository.Signing.SigningName,
75+
Email: setting.Repository.Signing.SigningEmail,
76+
}
77+
}

modules/git/url/url_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ func TestParseGitURLs(t *testing.T) {
3434
},
3535
},
3636
{
37-
kase: "git@[fe80:14fc:cec5:c174:d88%2510]:go-gitea/gitea.git",
37+
kase: "git@[fe80::14fc:cec5:c174:d88%2510]:go-gitea/gitea.git",
3838
expected: &GitURL{
3939
URL: &url.URL{
4040
Scheme: "ssh",
4141
User: url.User("git"),
42-
Host: "[fe80:14fc:cec5:c174:d88%10]",
42+
Host: "[fe80::14fc:cec5:c174:d88%10]",
4343
Path: "go-gitea/gitea.git",
4444
},
4545
extraMark: 1,
@@ -137,11 +137,11 @@ func TestParseGitURLs(t *testing.T) {
137137
},
138138
},
139139
{
140-
kase: "https://[fe80:14fc:cec5:c174:d88%2510]:20/go-gitea/gitea.git",
140+
kase: "https://[fe80::14fc:cec5:c174:d88%2510]:20/go-gitea/gitea.git",
141141
expected: &GitURL{
142142
URL: &url.URL{
143143
Scheme: "https",
144-
Host: "[fe80:14fc:cec5:c174:d88%10]:20",
144+
Host: "[fe80::14fc:cec5:c174:d88%10]:20",
145145
Path: "/go-gitea/gitea.git",
146146
},
147147
extraMark: 0,

modules/gitrepo/clone.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package gitrepo
5+
6+
import (
7+
"context"
8+
9+
"code.gitea.io/gitea/modules/git"
10+
)
11+
12+
// CloneExternalRepo clones an external repository to the managed repository.
13+
func CloneExternalRepo(ctx context.Context, fromRemoteURL string, toRepo Repository, opts git.CloneRepoOptions) error {
14+
return git.Clone(ctx, fromRemoteURL, repoPath(toRepo), opts)
15+
}
16+
17+
// CloneRepoToLocal clones a managed repository to a local path.
18+
func CloneRepoToLocal(ctx context.Context, fromRepo Repository, toLocalPath string, opts git.CloneRepoOptions) error {
19+
return git.Clone(ctx, repoPath(fromRepo), toLocalPath, opts)
20+
}

modules/gitrepo/commitgraph.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package gitrepo
5+
6+
import (
7+
"context"
8+
9+
"code.gitea.io/gitea/modules/git"
10+
)
11+
12+
func WriteCommitGraph(ctx context.Context, repo Repository) error {
13+
return git.WriteCommitGraph(ctx, repoPath(repo))
14+
}

0 commit comments

Comments
 (0)