Skip to content

Commit 8ced437

Browse files
committed
remove unused codes
1 parent 624cca6 commit 8ced437

File tree

2 files changed

+0
-68
lines changed

2 files changed

+0
-68
lines changed

models/user.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -615,20 +615,6 @@ func (u *User) GetRepositories(page, pageSize int) (err error) {
615615
return err
616616
}
617617

618-
// GetRepositoryIDs returns repositories IDs where user owned and has unittypes
619-
func (u *User) GetRepositoryIDs(units ...UnitType) ([]int64, error) {
620-
var ids []int64
621-
622-
sess := x.Table("repository").Cols("repository.id")
623-
624-
if len(units) > 0 {
625-
sess = sess.Join("INNER", "repo_unit", "repository.id = repo_unit.repo_id")
626-
sess = sess.In("repo_unit.type", units)
627-
}
628-
629-
return ids, sess.Where("owner_id = ?", u.ID).Find(&ids)
630-
}
631-
632618
// UnitRepositoriesSubQuery returns repositories query builder according units
633619
func (u *User) UnitRepositoriesSubQuery(units ...UnitType) *builder.Builder {
634620
b := builder.Select("repository.id").From("repository")
@@ -640,38 +626,6 @@ func (u *User) UnitRepositoriesSubQuery(units ...UnitType) *builder.Builder {
640626
return b.Where(builder.Eq{"owner_id": u.ID})
641627
}
642628

643-
// GetOrgRepositoryIDs returns repositories IDs where user's team owned and has unittypes
644-
func (u *User) GetOrgRepositoryIDs(units ...UnitType) ([]int64, error) {
645-
var ids []int64
646-
647-
sess := x.Table("repository").
648-
Cols("repository.id").
649-
Join("INNER", "team_user", "repository.owner_id = team_user.org_id").
650-
Join("INNER", "team_repo", "repository.is_private != ? OR (team_user.team_id = team_repo.team_id AND repository.id = team_repo.repo_id)", true)
651-
652-
if len(units) > 0 {
653-
sess = sess.Join("INNER", "team_unit", "team_unit.team_id = team_user.team_id")
654-
sess = sess.In("team_unit.type", units)
655-
}
656-
657-
return ids, sess.
658-
Where("team_user.uid = ?", u.ID).
659-
GroupBy("repository.id").Find(&ids)
660-
}
661-
662-
// GetAccessRepoIDs returns all repositories IDs where user's or user is a team member organizations
663-
func (u *User) GetAccessRepoIDs(units ...UnitType) ([]int64, error) {
664-
ids, err := u.GetRepositoryIDs(units...)
665-
if err != nil {
666-
return nil, err
667-
}
668-
ids2, err := u.GetOrgRepositoryIDs(units...)
669-
if err != nil {
670-
return nil, err
671-
}
672-
return append(ids, ids2...), nil
673-
}
674-
675629
// GetMirrorRepositories returns mirror repositories that user owns, including private repositories.
676630
func (u *User) GetMirrorRepositories() ([]*Repository, error) {
677631
return GetUserMirrorRepositories(u.ID)

models/user_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -275,28 +275,6 @@ func BenchmarkHashPassword(b *testing.B) {
275275
}
276276
}
277277

278-
func TestGetOrgRepositoryIDs(t *testing.T) {
279-
assert.NoError(t, PrepareTestDatabase())
280-
user2 := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
281-
user4 := AssertExistsAndLoadBean(t, &User{ID: 4}).(*User)
282-
user5 := AssertExistsAndLoadBean(t, &User{ID: 5}).(*User)
283-
284-
accessibleRepos, err := user2.GetOrgRepositoryIDs()
285-
assert.NoError(t, err)
286-
// User 2's team has access to private repos 3, 5, repo 32 is a public repo of the organization
287-
assert.Equal(t, []int64{3, 5, 23, 24, 32}, accessibleRepos)
288-
289-
accessibleRepos, err = user4.GetOrgRepositoryIDs()
290-
assert.NoError(t, err)
291-
// User 4's team has access to private repo 3, repo 32 is a public repo of the organization
292-
assert.Equal(t, []int64{3, 32}, accessibleRepos)
293-
294-
accessibleRepos, err = user5.GetOrgRepositoryIDs()
295-
assert.NoError(t, err)
296-
// User 5's team has no access to any repo
297-
assert.Len(t, accessibleRepos, 0)
298-
}
299-
300278
func TestNewGitSig(t *testing.T) {
301279
users := make([]*User, 0, 20)
302280
sess := x.NewSession()

0 commit comments

Comments
 (0)