Skip to content

Commit cb340f4

Browse files
committed
Merge
1 parent 7129e28 commit cb340f4

File tree

3 files changed

+4
-111
lines changed

3 files changed

+4
-111
lines changed

models/issue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,9 +1186,9 @@ type IssuesOptions struct {
11861186
// prioritize issues from this repo
11871187
PriorityRepoID int64
11881188
IsArchived util.OptionalBool
1189-
Org *Organization // issues permission scope
1190-
Team *Team // issues permission scope
1191-
User *User // issues permission scope
1189+
Org *Organization // issues permission scope
1190+
Team *Team // issues permission scope
1191+
User *user_model.User // issues permission scope
11921192
}
11931193

11941194
// sortIssuesSession sort an issues-related session based on the provided

models/repo_list.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import (
1212
"code.gitea.io/gitea/models/perm"
1313
repo_model "code.gitea.io/gitea/models/repo"
1414
"code.gitea.io/gitea/models/unit"
15-
<<<<<<< HEAD
1615
user_model "code.gitea.io/gitea/models/user"
17-
=======
18-
>>>>>>> f548ff512 (Fix test)
1916
"code.gitea.io/gitea/modules/structs"
2017
"code.gitea.io/gitea/modules/util"
2118

@@ -311,7 +308,7 @@ func userOrgPublicRepoCondPrivate(userID int64) builder.Cond {
311308
Join("INNER", "`user`", "`user`.id = `org_user`.org_id").
312309
Where(builder.Eq{
313310
"`org_user`.uid": userID,
314-
"`user`.type": UserTypeOrganization,
311+
"`user`.type": user_model.UserTypeOrganization,
315312
"`user`.visibility": structs.VisibleTypePrivate,
316313
}),
317314
),

models/user.go

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
asymkey_model "code.gitea.io/gitea/models/asymkey"
1616
"code.gitea.io/gitea/models/db"
1717
repo_model "code.gitea.io/gitea/models/repo"
18-
"code.gitea.io/gitea/models/unit"
1918
user_model "code.gitea.io/gitea/models/user"
2019
"code.gitea.io/gitea/modules/setting"
2120
"code.gitea.io/gitea/modules/structs"
@@ -30,109 +29,6 @@ func GetOrganizationCount(ctx context.Context, u *user_model.User) (int64, error
3029
Count(new(OrgUser))
3130
}
3231

33-
// GetRepositoryIDs returns repositories IDs where user owned and has unittypes
34-
// Caller shall check that units is not globally disabled
35-
func GetRepositoryIDs(u *user_model.User, units ...unit.Type) ([]int64, error) {
36-
var ids []int64
37-
38-
sess := db.GetEngine(db.DefaultContext).Table("repository").Cols("repository.id")
39-
40-
if len(units) > 0 {
41-
sess = sess.Join("INNER", "repo_unit", "repository.id = repo_unit.repo_id")
42-
sess = sess.In("repo_unit.type", units)
43-
}
44-
45-
return ids, sess.Where("owner_id = ?", u.ID).Find(&ids)
46-
}
47-
48-
// GetActiveRepositoryIDs returns non-archived repositories IDs where user owned and has unittypes
49-
// Caller shall check that units is not globally disabled
50-
func GetActiveRepositoryIDs(u *user_model.User, units ...unit.Type) ([]int64, error) {
51-
var ids []int64
52-
53-
sess := db.GetEngine(db.DefaultContext).Table("repository").Cols("repository.id")
54-
55-
if len(units) > 0 {
56-
sess = sess.Join("INNER", "repo_unit", "repository.id = repo_unit.repo_id")
57-
sess = sess.In("repo_unit.type", units)
58-
}
59-
60-
sess.Where(builder.Eq{"is_archived": false})
61-
62-
return ids, sess.Where("owner_id = ?", u.ID).GroupBy("repository.id").Find(&ids)
63-
}
64-
65-
// GetOrgRepositoryIDs returns repositories IDs where user's team owned and has unittypes
66-
// Caller shall check that units is not globally disabled
67-
func GetOrgRepositoryIDs(u *user_model.User, units ...unit.Type) ([]int64, error) {
68-
var ids []int64
69-
70-
if err := db.GetEngine(db.DefaultContext).Table("repository").
71-
Cols("repository.id").
72-
Join("INNER", "team_user", "repository.owner_id = team_user.org_id").
73-
Join("INNER", "team_repo", "(? != ? and repository.is_private != ?) OR (team_user.team_id = team_repo.team_id AND repository.id = team_repo.repo_id)", true, u.IsRestricted, true).
74-
Where("team_user.uid = ?", u.ID).
75-
GroupBy("repository.id").Find(&ids); err != nil {
76-
return nil, err
77-
}
78-
79-
if len(units) > 0 {
80-
return FilterOutRepoIdsWithoutUnitAccess(u, ids, units...)
81-
}
82-
83-
return ids, nil
84-
}
85-
86-
// GetActiveOrgRepositoryIDs returns non-archived repositories IDs where user's team owned and has unittypes
87-
// Caller shall check that units is not globally disabled
88-
func GetActiveOrgRepositoryIDs(u *user_model.User, units ...unit.Type) ([]int64, error) {
89-
var ids []int64
90-
91-
if err := db.GetEngine(db.DefaultContext).Table("repository").
92-
Cols("repository.id").
93-
Join("INNER", "team_user", "repository.owner_id = team_user.org_id").
94-
Join("INNER", "team_repo", "(? != ? and repository.is_private != ?) OR (team_user.team_id = team_repo.team_id AND repository.id = team_repo.repo_id)", true, u.IsRestricted, true).
95-
Where("team_user.uid = ?", u.ID).
96-
Where(builder.Eq{"is_archived": false}).
97-
GroupBy("repository.id").Find(&ids); err != nil {
98-
return nil, err
99-
}
100-
101-
if len(units) > 0 {
102-
return FilterOutRepoIdsWithoutUnitAccess(u, ids, units...)
103-
}
104-
105-
return ids, nil
106-
}
107-
108-
// GetAccessRepoIDs returns all repositories IDs where user's or user is a team member organizations
109-
// Caller shall check that units is not globally disabled
110-
func GetAccessRepoIDs(u *user_model.User, units ...unit.Type) ([]int64, error) {
111-
ids, err := GetRepositoryIDs(u, units...)
112-
if err != nil {
113-
return nil, err
114-
}
115-
ids2, err := GetOrgRepositoryIDs(u, units...)
116-
if err != nil {
117-
return nil, err
118-
}
119-
return append(ids, ids2...), nil
120-
}
121-
122-
// GetActiveAccessRepoIDs returns all non-archived repositories IDs where user's or user is a team member organizations
123-
// Caller shall check that units is not globally disabled
124-
func GetActiveAccessRepoIDs(u *user_model.User, units ...unit.Type) ([]int64, error) {
125-
ids, err := GetActiveRepositoryIDs(u, units...)
126-
if err != nil {
127-
return nil, err
128-
}
129-
ids2, err := GetActiveOrgRepositoryIDs(u, units...)
130-
if err != nil {
131-
return nil, err
132-
}
133-
return append(ids, ids2...), nil
134-
}
135-
13632
// deleteBeans deletes all given beans, beans should contain delete conditions.
13733
func deleteBeans(e db.Engine, beans ...interface{}) (err error) {
13834
for i := range beans {

0 commit comments

Comments
 (0)