Skip to content

Commit 8ca9949

Browse files
committed
Merge branch 'main' into lunny/use_git_model
2 parents b61ac43 + ad2ff67 commit 8ca9949

File tree

85 files changed

+2170
-2152
lines changed

Some content is hidden

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

85 files changed

+2170
-2152
lines changed

cmd/admin_user_create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func runCreateUser(ctx context.Context, c *cli.Command) error {
151151
if err != nil {
152152
return err
153153
}
154+
// codeql[disable-next-line=go/clear-text-logging]
154155
fmt.Printf("generated random password is '%s'\n", password)
155156
} else if userType == user_model.UserTypeIndividual {
156157
return errors.New("must set either password or random-password flag")

cmd/admin_user_must_change_password.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func runMustChangePassword(ctx context.Context, c *cli.Command) error {
5858
return err
5959
}
6060

61+
// codeql[disable-next-line=go/clear-text-logging]
6162
fmt.Printf("Updated %d users setting MustChangePassword to %t\n", n, mustChangePassword)
6263
return nil
6364
}

cmd/generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func runGenerateSecretKey(_ context.Context, c *cli.Command) error {
9191
return err
9292
}
9393

94+
// codeql[disable-next-line=go/clear-text-logging]
9495
fmt.Printf("%s", secretKey)
9596

9697
if isatty.IsTerminal(os.Stdout.Fd()) {

cmd/hook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Gitea or set your environment appropriately.`, "")
186186
userID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
187187
prID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPRID), 10, 64)
188188
deployKeyID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvDeployKeyID), 10, 64)
189-
actionPerm, _ := strconv.ParseInt(os.Getenv(repo_module.EnvActionPerm), 10, 64)
189+
actionPerm, _ := strconv.Atoi(os.Getenv(repo_module.EnvActionPerm))
190190

191191
hookOptions := private.HookOptions{
192192
UserID: userID,
@@ -196,7 +196,7 @@ Gitea or set your environment appropriately.`, "")
196196
GitPushOptions: pushOptions(),
197197
PullRequestID: prID,
198198
DeployKeyID: deployKeyID,
199-
ActionPerm: int(actionPerm),
199+
ActionPerm: actionPerm,
200200
}
201201

202202
scanner := bufio.NewScanner(os.Stdin)

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ require (
109109
github.com/ulikunitz/xz v0.5.15
110110
github.com/urfave/cli-docs/v3 v3.0.0-alpha6
111111
github.com/urfave/cli/v3 v3.4.1
112-
github.com/wneessen/go-mail v0.6.2
112+
github.com/wneessen/go-mail v0.7.1
113113
github.com/xeipuuv/gojsonschema v1.2.0
114114
github.com/yohcop/openid-go v1.0.1
115115
github.com/yuin/goldmark v1.7.13
@@ -120,9 +120,9 @@ require (
120120
golang.org/x/image v0.30.0
121121
golang.org/x/net v0.43.0
122122
golang.org/x/oauth2 v0.30.0
123-
golang.org/x/sync v0.16.0
123+
golang.org/x/sync v0.17.0
124124
golang.org/x/sys v0.35.0
125-
golang.org/x/text v0.28.0
125+
golang.org/x/text v0.29.0
126126
google.golang.org/grpc v1.75.0
127127
google.golang.org/protobuf v1.36.8
128128
gopkg.in/ini.v1 v1.67.0
@@ -295,7 +295,7 @@ replace github.com/jaytaylor/html2text => github.com/Necoro/html2text v0.0.0-202
295295

296296
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
297297

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

300300
// TODO: the only difference is in `PutObject`: the fork doesn't use `NewVerifyingReader(r, sha256.New(), oid, expectedSize)`, need to figure out why
301301
replace github.com/charmbracelet/git-lfs-transfer => gitea.com/gitea/git-lfs-transfer v0.2.0

go.sum

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
3131
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
3232
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
3333
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
34-
gitea.com/gitea/act v0.261.6 h1:CjZwKOyejonNFDmsXOw3wGm5Vet573hHM6VMLsxtvPY=
35-
gitea.com/gitea/act v0.261.6/go.mod h1:Pg5C9kQY1CEA3QjthjhlrqOC/QOT5NyWNjOjRHw23Ok=
34+
gitea.com/gitea/act v0.261.7-0.20251003180512-ac6e4b751763 h1:ohdxegvslDEllZmRNDqpKun6L4Oq81jNdEDtGgHEV2c=
35+
gitea.com/gitea/act v0.261.7-0.20251003180512-ac6e4b751763/go.mod h1:Pg5C9kQY1CEA3QjthjhlrqOC/QOT5NyWNjOjRHw23Ok=
3636
gitea.com/gitea/git-lfs-transfer v0.2.0 h1:baHaNoBSRaeq/xKayEXwiDQtlIjps4Ac/Ll4KqLMB40=
3737
gitea.com/gitea/git-lfs-transfer v0.2.0/go.mod h1:UrXUCm3xLQkq15fu7qlXHUMlrhdlXHoi13KH2Dfiits=
3838
gitea.com/gitea/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:BAFmdZpRW7zMQZQDClaCWobRj9uL1MR3MzpCVJvc5s4=
@@ -765,8 +765,8 @@ github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZ
765765
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
766766
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
767767
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
768-
github.com/wneessen/go-mail v0.6.2 h1:c6V7c8D2mz868z9WJ+8zDKtUyLfZ1++uAZmo2GRFji8=
769-
github.com/wneessen/go-mail v0.6.2/go.mod h1:L/PYjPK3/2ZlNb2/FjEBIn9n1rUWjW+Toy531oVmeb4=
768+
github.com/wneessen/go-mail v0.7.1 h1:rvy63sp14N06/kdGqCYwW8Na5gDCXjTQM1E7So4PuKk=
769+
github.com/wneessen/go-mail v0.7.1/go.mod h1:+TkW6QP3EVkgTEqHtVmnAE/1MRhmzb8Y9/W3pweuS+k=
770770
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
771771
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
772772
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
@@ -837,7 +837,6 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf
837837
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
838838
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
839839
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
840-
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
841840
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
842841
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
843842
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -930,9 +929,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
930929
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
931930
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
932931
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
933-
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
934-
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
935-
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
932+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
933+
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
936934
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
937935
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
938936
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -974,7 +972,6 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
974972
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
975973
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
976974
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
977-
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
978975
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
979976
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
980977
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
@@ -987,7 +984,6 @@ golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
987984
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
988985
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
989986
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
990-
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
991987
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
992988
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
993989
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1003,9 +999,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
1003999
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
10041000
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
10051001
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
1006-
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
1007-
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
1008-
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
1002+
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
1003+
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
10091004
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
10101005
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
10111006
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=

models/fixtures/branch.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,23 @@
216216

217217
-
218218
id: 26
219-
repo_id: 1
220-
name: 'DefaultBranch'
221-
commit_id: '90c1019714259b24fb81711d4416ac0f18667dfa'
222-
commit_message: 'add license'
223-
commit_time: 1709345946
219+
repo_id: 10
220+
name: 'feature/1'
221+
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
222+
commit_message: 'Initial commit'
223+
commit_time: 1489950479
224224
pusher_id: 2
225225
is_deleted: false
226226
deleted_by_id: 0
227227
deleted_unix: 0
228228

229229
-
230230
id: 27
231-
repo_id: 10
232-
name: 'feature/1'
233-
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
234-
commit_message: "Initial commit"
235-
commit_time: 1489927679
231+
repo_id: 1
232+
name: 'DefaultBranch'
233+
commit_id: '90c1019714259b24fb81711d4416ac0f18667dfa'
234+
commit_message: 'add license'
235+
commit_time: 1709345946
236236
pusher_id: 1
237237
is_deleted: false
238238
deleted_by_id: 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2025 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
package git
4+
package repo
55

66
import (
77
"testing"

models/repo/archiver.go

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"time"
1212

1313
"code.gitea.io/gitea/models/db"
14-
"code.gitea.io/gitea/modules/git"
1514
"code.gitea.io/gitea/modules/timeutil"
1615
"code.gitea.io/gitea/modules/util"
1716

@@ -27,11 +26,46 @@ const (
2726
ArchiverReady // it's ready
2827
)
2928

29+
// ArchiveType archive types
30+
type ArchiveType int
31+
32+
const (
33+
ArchiveUnknown ArchiveType = iota
34+
ArchiveZip // 1
35+
ArchiveTarGz // 2
36+
ArchiveBundle // 3
37+
)
38+
39+
// String converts an ArchiveType to string: the extension of the archive file without prefix dot
40+
func (a ArchiveType) String() string {
41+
switch a {
42+
case ArchiveZip:
43+
return "zip"
44+
case ArchiveTarGz:
45+
return "tar.gz"
46+
case ArchiveBundle:
47+
return "bundle"
48+
}
49+
return "unknown"
50+
}
51+
52+
func SplitArchiveNameType(s string) (string, ArchiveType) {
53+
switch {
54+
case strings.HasSuffix(s, ".zip"):
55+
return strings.TrimSuffix(s, ".zip"), ArchiveZip
56+
case strings.HasSuffix(s, ".tar.gz"):
57+
return strings.TrimSuffix(s, ".tar.gz"), ArchiveTarGz
58+
case strings.HasSuffix(s, ".bundle"):
59+
return strings.TrimSuffix(s, ".bundle"), ArchiveBundle
60+
}
61+
return s, ArchiveUnknown
62+
}
63+
3064
// RepoArchiver represents all archivers
3165
type RepoArchiver struct { //revive:disable-line:exported
32-
ID int64 `xorm:"pk autoincr"`
33-
RepoID int64 `xorm:"index unique(s)"`
34-
Type git.ArchiveType `xorm:"unique(s)"`
66+
ID int64 `xorm:"pk autoincr"`
67+
RepoID int64 `xorm:"index unique(s)"`
68+
Type ArchiveType `xorm:"unique(s)"`
3569
Status ArchiverStatus
3670
CommitID string `xorm:"VARCHAR(64) unique(s)"`
3771
CreatedUnix timeutil.TimeStamp `xorm:"INDEX NOT NULL created"`
@@ -56,15 +90,15 @@ func repoArchiverForRelativePath(relativePath string) (*RepoArchiver, error) {
5690
if err != nil {
5791
return nil, util.NewInvalidArgumentErrorf("invalid storage path: invalid repo id")
5892
}
59-
commitID, archiveType := git.SplitArchiveNameType(parts[2])
60-
if archiveType == git.ArchiveUnknown {
93+
commitID, archiveType := SplitArchiveNameType(parts[2])
94+
if archiveType == ArchiveUnknown {
6195
return nil, util.NewInvalidArgumentErrorf("invalid storage path: invalid archive type")
6296
}
6397
return &RepoArchiver{RepoID: repoID, CommitID: commitID, Type: archiveType}, nil
6498
}
6599

66100
// GetRepoArchiver get an archiver
67-
func GetRepoArchiver(ctx context.Context, repoID int64, tp git.ArchiveType, commitID string) (*RepoArchiver, error) {
101+
func GetRepoArchiver(ctx context.Context, repoID int64, tp ArchiveType, commitID string) (*RepoArchiver, error) {
68102
var archiver RepoArchiver
69103
has, err := db.GetEngine(ctx).Where("repo_id=?", repoID).And("`type`=?", tp).And("commit_id=?", commitID).Get(&archiver)
70104
if err != nil {

models/repo/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ func (repo *Repository) IsGenerated() bool {
605605

606606
// RepoPath returns repository path by given user and repository name.
607607
func RepoPath(userName, repoName string) string { //revive:disable-line:exported
608-
return filepath.Join(user_model.UserPath(userName), strings.ToLower(repoName)+".git")
608+
return filepath.Join(setting.RepoRootPath, filepath.Clean(strings.ToLower(userName)), filepath.Clean(strings.ToLower(repoName)+".git"))
609609
}
610610

611611
// RepoPath returns the repository path

0 commit comments

Comments
 (0)