@@ -227,6 +227,7 @@ func userMentionedRepoCond(id string, userID int64) builder.Cond {
227
227
)
228
228
}
229
229
230
+ // teamUnitsRepoCond returns query condition for those repo id in the special org team with special units access
230
231
func teamUnitsRepoCond (id string , userID , orgID , teamID int64 , units ... unit.Type ) builder.Cond {
231
232
return builder .In (id ,
232
233
builder .Select ("repo_id" ).From ("team_repo" ).Where (
@@ -253,7 +254,7 @@ func teamUnitsRepoCond(id string, userID, orgID, teamID int64, units ...unit.Typ
253
254
))
254
255
}
255
256
256
- // userCollaborationRepoCond return user as collabrators repositories list
257
+ // userCollaborationRepoCond returns user as collabrators repositories list
257
258
func userCollaborationRepoCond (idStr string , userID int64 ) builder.Cond {
258
259
return builder .In (idStr , builder .Select ("repo_id" ).
259
260
From ("`access`" ).
@@ -264,30 +265,35 @@ func userCollaborationRepoCond(idStr string, userID int64) builder.Cond {
264
265
)
265
266
}
266
267
268
+ // userOrgTeamRepoCond selects repos that the given user has access to through team membership
267
269
func userOrgTeamRepoCond (idStr string , userID int64 ) builder.Cond {
268
270
return builder .In (idStr , userOrgTeamRepoBuilder (userID ))
269
271
}
270
272
273
+ // userOrgTeamRepoBuilder returns repo ids where user's teams can access.
271
274
func userOrgTeamRepoBuilder (userID int64 ) * builder.Builder {
272
275
return builder .Select ("`team_repo`.repo_id" ).
273
276
From ("team_repo" ).
274
277
Join ("INNER" , "team_user" , "`team_user`.team_id = `team_repo`.team_id" ).
275
278
Where (builder.Eq {"`team_user`.uid" : userID })
276
279
}
277
280
281
+ // userOrgTeamUnitRepoBuilder returns repo ids where user's teams can access the special unit.
278
282
func userOrgTeamUnitRepoBuilder (userID int64 , unitType unit.Type ) * builder.Builder {
279
283
return userOrgTeamRepoBuilder (userID ).
280
284
Join ("INNER" , "team_unit" , "`team_unit`.team_id = `team_repo`.team_id" ).
281
285
Where (builder.Eq {"`team_unit`.`type`" : unitType })
282
286
}
283
287
288
+ // userOrgUnitRepoCond selects repos that the given user has access to through org and the special unit
284
289
func userOrgUnitRepoCond (idStr string , userID , orgID int64 , unitType unit.Type ) builder.Cond {
285
290
return builder .In (idStr ,
286
291
userOrgTeamUnitRepoBuilder (userID , unitType ).
287
292
And (builder.Eq {"org_id" : orgID }),
288
293
)
289
294
}
290
295
296
+ // userOrgPublicRepoCond returns the condition that one user could access all public repositories in organizations
291
297
func userOrgPublicRepoCond (userID int64 ) builder.Cond {
292
298
return builder .And (
293
299
builder.Eq {"`repository`.is_private" : false },
@@ -299,6 +305,7 @@ func userOrgPublicRepoCond(userID int64) builder.Cond {
299
305
)
300
306
}
301
307
308
+ // userOrgPublicRepoCondPrivate returns the condition that one user could access all public repositories in private organizations
302
309
func userOrgPublicRepoCondPrivate (userID int64 ) builder.Cond {
303
310
return builder .And (
304
311
builder.Eq {"`repository`.is_private" : false },
@@ -315,6 +322,7 @@ func userOrgPublicRepoCondPrivate(userID int64) builder.Cond {
315
322
)
316
323
}
317
324
325
+ // userOrgPublicUnitRepoCond returns the condition that one user could access all public repositories in the special organization
318
326
func userOrgPublicUnitRepoCond (userID , orgID int64 ) builder.Cond {
319
327
return userOrgPublicRepoCond (userID ).
320
328
And (builder.Eq {"`repository`.owner_id" : orgID })
0 commit comments