@@ -8,7 +8,6 @@ package repo
8
8
import (
9
9
"context"
10
10
"errors"
11
- "fmt"
12
11
"time"
13
12
14
13
"code.gitea.io/gitea/models/db"
@@ -121,55 +120,3 @@ func InsertMirror(ctx context.Context, mirror *Mirror) error {
121
120
_ , err := db .GetEngine (ctx ).Insert (mirror )
122
121
return err
123
122
}
124
-
125
- // MirrorRepositoryList contains the mirror repositories
126
- type MirrorRepositoryList []* Repository
127
-
128
- func (repos MirrorRepositoryList ) loadAttributes (ctx context.Context ) error {
129
- if len (repos ) == 0 {
130
- return nil
131
- }
132
-
133
- // Load mirrors.
134
- repoIDs := make ([]int64 , 0 , len (repos ))
135
- for i := range repos {
136
- if ! repos [i ].IsMirror {
137
- continue
138
- }
139
-
140
- repoIDs = append (repoIDs , repos [i ].ID )
141
- }
142
- mirrors := make ([]* Mirror , 0 , len (repoIDs ))
143
- if err := db .GetEngine (ctx ).
144
- Where ("id > 0" ).
145
- In ("repo_id" , repoIDs ).
146
- Find (& mirrors ); err != nil {
147
- return fmt .Errorf ("find mirrors: %v" , err )
148
- }
149
-
150
- set := make (map [int64 ]* Mirror )
151
- for i := range mirrors {
152
- set [mirrors [i ].RepoID ] = mirrors [i ]
153
- }
154
- for i := range repos {
155
- repos [i ].Mirror = set [repos [i ].ID ]
156
- if repos [i ].Mirror != nil {
157
- repos [i ].Mirror .Repo = repos [i ]
158
- }
159
- }
160
- return nil
161
- }
162
-
163
- // LoadAttributes loads the attributes for the given MirrorRepositoryList
164
- func (repos MirrorRepositoryList ) LoadAttributes () error {
165
- return repos .loadAttributes (db .DefaultContext )
166
- }
167
-
168
- // GetUserMirrorRepositories returns a list of mirror repositories of given user.
169
- func GetUserMirrorRepositories (userID int64 ) ([]* Repository , error ) {
170
- repos := make ([]* Repository , 0 , 10 )
171
- return repos , db .GetEngine (db .DefaultContext ).
172
- Where ("owner_id = ?" , userID ).
173
- And ("is_mirror = ?" , true ).
174
- Find (& repos )
175
- }
0 commit comments