Skip to content

Commit eb86fcb

Browse files
authored
Merge branch 'main' into archived-lable-highglight-via-linear-gradient
2 parents 58b3f4e + 603fca1 commit eb86fcb

File tree

151 files changed

+3198
-620
lines changed

Some content is hidden

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

151 files changed

+3198
-620
lines changed

cmd/hook.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,9 @@ Gitea or set your environment appropriately.`, "")
591591
// S: ... ...
592592
// S: flush-pkt
593593
hookOptions := private.HookOptions{
594-
UserName: pusherName,
595-
UserID: pusherID,
594+
UserName: pusherName,
595+
UserID: pusherID,
596+
GitPushOptions: make(map[string]string),
596597
}
597598
hookOptions.OldCommitIDs = make([]string, 0, hookBatchSize)
598599
hookOptions.NewCommitIDs = make([]string, 0, hookBatchSize)
@@ -617,8 +618,6 @@ Gitea or set your environment appropriately.`, "")
617618
hookOptions.RefFullNames = append(hookOptions.RefFullNames, git.RefName(t[2]))
618619
}
619620

620-
hookOptions.GitPushOptions = make(map[string]string)
621-
622621
if hasPushOptions {
623622
for {
624623
rs, err = readPktLine(ctx, reader, pktLineTypeUnknow)
@@ -629,11 +628,7 @@ Gitea or set your environment appropriately.`, "")
629628
if rs.Type == pktLineTypeFlush {
630629
break
631630
}
632-
633-
kv := strings.SplitN(string(rs.Data), "=", 2)
634-
if len(kv) == 2 {
635-
hookOptions.GitPushOptions[kv[0]] = kv[1]
636-
}
631+
hookOptions.GitPushOptions.AddFromKeyValue(string(rs.Data))
637632
}
638633
}
639634

models/fixtures/repo_unit.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,3 +712,24 @@
712712
type: 3
713713
config: "{\"IgnoreWhitespaceConflicts\":false,\"AllowMerge\":true,\"AllowRebase\":true,\"AllowRebaseMerge\":true,\"AllowSquash\":true}"
714714
created_unix: 946684810
715+
716+
-
717+
id: 108
718+
repo_id: 62
719+
type: 1
720+
config: "{}"
721+
created_unix: 946684810
722+
723+
-
724+
id: 109
725+
repo_id: 62
726+
type: 2
727+
config: "{\"EnableTimetracker\":true,\"AllowOnlyContributorsToTrackTime\":true}"
728+
created_unix: 946684810
729+
730+
-
731+
id: 110
732+
repo_id: 62
733+
type: 3
734+
config: "{\"IgnoreWhitespaceConflicts\":false,\"AllowMerge\":true,\"AllowRebase\":true,\"AllowRebaseMerge\":true,\"AllowSquash\":true}"
735+
created_unix: 946684810

models/fixtures/repository.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,3 +1768,34 @@
17681768
size: 0
17691769
is_fsck_enabled: true
17701770
close_issues_via_commit_in_any_branch: false
1771+
1772+
-
1773+
id: 62
1774+
owner_id: 42
1775+
owner_name: org42
1776+
lower_name: search-by-path
1777+
name: search-by-path
1778+
default_branch: master
1779+
num_watches: 0
1780+
num_stars: 0
1781+
num_forks: 0
1782+
num_issues: 0
1783+
num_closed_issues: 0
1784+
num_pulls: 0
1785+
num_closed_pulls: 0
1786+
num_milestones: 0
1787+
num_closed_milestones: 0
1788+
num_projects: 0
1789+
num_closed_projects: 0
1790+
is_private: false
1791+
is_empty: false
1792+
is_archived: false
1793+
is_mirror: false
1794+
status: 0
1795+
is_fork: false
1796+
fork_id: 0
1797+
is_template: false
1798+
template_id: 0
1799+
size: 0
1800+
is_fsck_enabled: true
1801+
close_issues_via_commit_in_any_branch: false

models/fixtures/user.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,3 +1517,40 @@
15171517
repo_admin_change_team_access: false
15181518
theme: ""
15191519
keep_activity_private: false
1520+
1521+
-
1522+
id: 42
1523+
lower_name: org42
1524+
name: org42
1525+
full_name: Org42
1526+
1527+
keep_email_private: false
1528+
email_notifications_preference: onmention
1529+
passwd: ZogKvWdyEx:password
1530+
passwd_hash_algo: dummy
1531+
must_change_password: false
1532+
login_source: 0
1533+
login_name: org42
1534+
type: 1
1535+
salt: ZogKvWdyEx
1536+
max_repo_creation: -1
1537+
is_active: false
1538+
is_admin: false
1539+
is_restricted: false
1540+
allow_git_hook: false
1541+
allow_import_local: false
1542+
allow_create_organization: true
1543+
prohibit_login: false
1544+
avatar: avatar42
1545+
avatar_email: [email protected]
1546+
use_custom_avatar: false
1547+
num_followers: 0
1548+
num_following: 0
1549+
num_stars: 0
1550+
num_repos: 1
1551+
num_teams: 0
1552+
num_members: 0
1553+
visibility: 0
1554+
repo_admin_change_team_access: false
1555+
theme: ""
1556+
keep_activity_private: false

models/issues/pull_list.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type PullRequestsOptions struct {
2626
SortType string
2727
Labels []int64
2828
MilestoneID int64
29+
PosterID int64
2930
}
3031

3132
func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) *xorm.Session {
@@ -46,6 +47,10 @@ func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullR
4647
sess.And("issue.milestone_id=?", opts.MilestoneID)
4748
}
4849

50+
if opts.PosterID > 0 {
51+
sess.And("issue.poster_id=?", opts.PosterID)
52+
}
53+
4954
return sess
5055
}
5156

models/repo/repo_list_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ func getTestCases() []struct {
138138
{
139139
name: "AllPublic/PublicRepositoriesOfUserIncludingCollaborative",
140140
opts: &repo_model.SearchRepoOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, AllPublic: true, Template: optional.Some(false)},
141-
count: 33,
141+
count: 34,
142142
},
143143
{
144144
name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative",
145145
opts: &repo_model.SearchRepoOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, Private: true, AllPublic: true, AllLimited: true, Template: optional.Some(false)},
146-
count: 38,
146+
count: 39,
147147
},
148148
{
149149
name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName",
@@ -158,7 +158,7 @@ func getTestCases() []struct {
158158
{
159159
name: "AllPublic/PublicRepositoriesOfOrganization",
160160
opts: &repo_model.SearchRepoOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 10}, OwnerID: 17, AllPublic: true, Collaborate: optional.Some(false), Template: optional.Some(false)},
161-
count: 33,
161+
count: 34,
162162
},
163163
{
164164
name: "AllTemplates",

models/user/user.go

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ func (u *User) IsIndividual() bool {
408408
return u.Type == UserTypeIndividual
409409
}
410410

411+
func (u *User) IsUser() bool {
412+
return u.Type == UserTypeIndividual || u.Type == UserTypeBot
413+
}
414+
411415
// IsBot returns whether or not the user is of type bot
412416
func (u *User) IsBot() bool {
413417
return u.Type == UserTypeBot
@@ -561,42 +565,43 @@ var (
561565
".",
562566
"..",
563567
".well-known",
564-
"admin",
565-
"api",
566-
"assets",
567-
"attachments",
568-
"avatar",
569-
"avatars",
568+
569+
"api", // gitea api
570+
"metrics", // prometheus metrics api
571+
"v2", // container registry api
572+
573+
"assets", // static asset files
574+
"attachments", // issue attachments
575+
576+
"avatar", // avatar by email hash
577+
"avatars", // user avatars by file name
578+
"repo-avatars",
579+
570580
"captcha",
571-
"commits",
572-
"debug",
573-
"error",
581+
"login", // oauth2 login
582+
"org", // org create/manage, or "/org/{org}", BUT if an org is named as "invite" then it goes wrong
583+
"repo", // repo create/migrate, etc
584+
"user", // user login/activate/settings, etc
585+
574586
"explore",
575-
"favicon.ico",
576-
"ghost",
577587
"issues",
578-
"login",
579-
"manifest.json",
580-
"metrics",
588+
"pulls",
581589
"milestones",
582-
"new",
583590
"notifications",
584-
"org",
585-
"pulls",
586-
"raw",
587-
"repo",
588-
"repo-avatars",
589-
"robots.txt",
590-
"search",
591-
"serviceworker.js",
592-
"ssh_info",
591+
592+
"favicon.ico",
593+
"manifest.json", // web app manifests
594+
"robots.txt", // search engine robots
595+
"sitemap.xml", // search engine sitemap
596+
"ssh_info", // agit info
593597
"swagger.v1.json",
594-
"user",
595-
"v2",
596-
"gitea-actions",
598+
599+
"ghost", // reserved name for deleted users (id: -1)
600+
"gitea-actions", // gitea builtin user (id: -2)
597601
}
598602

599-
// DON'T ADD ANY NEW STUFF, WE SOLVE THIS WITH `/user/{obj}` PATHS!
603+
// These names are reserved for user accounts: user's keys, user's rss feed, user's avatar, etc.
604+
// DO NOT add any new stuff! The paths with these names are processed by `/{username}` handler (UsernameSubRoute) manually.
600605
reservedUserPatterns = []string{"*.keys", "*.gpg", "*.rss", "*.atom", "*.png"}
601606
)
602607

models/user/user_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ func TestSearchUsers(t *testing.T) {
9292
testOrgSuccess(&user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 4, PageSize: 2}},
9393
[]int64{26, 41})
9494

95-
testOrgSuccess(&user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 5, PageSize: 2}},
95+
testOrgSuccess(&user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 5, PageSize: 2}},
96+
[]int64{42})
97+
98+
testOrgSuccess(&user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 6, PageSize: 2}},
9699
[]int64{})
97100

98101
// test users

modules/git/git.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ func SetExecutablePath(path string) error {
111111

112112
func ensureGitVersion() error {
113113
if !DefaultFeatures().CheckVersionAtLeast(RequiredVersion) {
114-
moreHint := "get git: https://git-scm.com/download/"
114+
moreHint := "get git: https://git-scm.com/downloads"
115115
if runtime.GOOS == "linux" {
116116
// there are a lot of CentOS/RHEL users using old git, so we add a special hint for them
117117
if _, err := os.Stat("/etc/redhat-release"); err == nil {
118118
// ius.io is the recommended official(git-scm.com) method to install git
119-
moreHint = "get git: https://git-scm.com/download/linux and https://ius.io"
119+
moreHint = "get git: https://git-scm.com/downloads/linux and https://ius.io"
120120
}
121121
}
122122
return fmt.Errorf("installed git version %q is not supported, Gitea requires git version >= %q, %s", DefaultFeatures().gitVersion.Original(), RequiredVersion, moreHint)

0 commit comments

Comments
 (0)