@@ -322,11 +322,6 @@ func (repo *Repository) APIURL() string {
322
322
return setting .AppURL + path .Join ("api/v1/repos" , repo .FullName ())
323
323
}
324
324
325
- // APIFormat converts a Repository to api.Repository
326
- func (repo * Repository ) APIFormat (mode AccessMode ) * api.Repository {
327
- return repo .innerAPIFormat (x , mode , false )
328
- }
329
-
330
325
// GetCommitsCountCacheKey returns cache key used for commits count caching.
331
326
func (repo * Repository ) GetCommitsCountCacheKey (contextName string , isRef bool ) string {
332
327
var prefix string
@@ -338,135 +333,6 @@ func (repo *Repository) GetCommitsCountCacheKey(contextName string, isRef bool)
338
333
return fmt .Sprintf ("commits-count-%d-%s-%s" , repo .ID , prefix , contextName )
339
334
}
340
335
341
- func (repo * Repository ) innerAPIFormat (e Engine , mode AccessMode , isParent bool ) * api.Repository {
342
- var parent * api.Repository
343
-
344
- cloneLink := repo .cloneLink (false )
345
- permission := & api.Permission {
346
- Admin : mode >= AccessModeAdmin ,
347
- Push : mode >= AccessModeWrite ,
348
- Pull : mode >= AccessModeRead ,
349
- }
350
- if ! isParent {
351
- err := repo .getBaseRepo (e )
352
- if err != nil {
353
- log .Error ("APIFormat: %v" , err )
354
- }
355
- if repo .BaseRepo != nil {
356
- parent = repo .BaseRepo .innerAPIFormat (e , mode , true )
357
- }
358
- }
359
-
360
- //check enabled/disabled units
361
- hasIssues := false
362
- var externalTracker * api.ExternalTracker
363
- var internalTracker * api.InternalTracker
364
- if unit , err := repo .getUnit (e , UnitTypeIssues ); err == nil {
365
- config := unit .IssuesConfig ()
366
- hasIssues = true
367
- internalTracker = & api.InternalTracker {
368
- EnableTimeTracker : config .EnableTimetracker ,
369
- AllowOnlyContributorsToTrackTime : config .AllowOnlyContributorsToTrackTime ,
370
- EnableIssueDependencies : config .EnableDependencies ,
371
- }
372
- } else if unit , err := repo .getUnit (e , UnitTypeExternalTracker ); err == nil {
373
- config := unit .ExternalTrackerConfig ()
374
- hasIssues = true
375
- externalTracker = & api.ExternalTracker {
376
- ExternalTrackerURL : config .ExternalTrackerURL ,
377
- ExternalTrackerFormat : config .ExternalTrackerFormat ,
378
- ExternalTrackerStyle : config .ExternalTrackerStyle ,
379
- }
380
- }
381
- hasUncyclo := false
382
- var externalUncyclo * api.ExternalUncyclo
383
- if _ , err := repo .getUnit (e , UnitTypeUncyclo ); err == nil {
384
- hasUncyclo = true
385
- } else if unit , err := repo .getUnit (e , UnitTypeExternalUncyclo ); err == nil {
386
- hasUncyclo = true
387
- config := unit .ExternalUncycloConfig ()
388
- externalUncyclo = & api.ExternalUncyclo {
389
- ExternalUncycloURL : config .ExternalUncycloURL ,
390
- }
391
- }
392
- hasPullRequests := false
393
- ignoreWhitespaceConflicts := false
394
- allowMerge := false
395
- allowRebase := false
396
- allowRebaseMerge := false
397
- allowSquash := false
398
- if unit , err := repo .getUnit (e , UnitTypePullRequests ); err == nil {
399
- config := unit .PullRequestsConfig ()
400
- hasPullRequests = true
401
- ignoreWhitespaceConflicts = config .IgnoreWhitespaceConflicts
402
- allowMerge = config .AllowMerge
403
- allowRebase = config .AllowRebase
404
- allowRebaseMerge = config .AllowRebaseMerge
405
- allowSquash = config .AllowSquash
406
- }
407
- hasProjects := false
408
- if _ , err := repo .getUnit (e , UnitTypeProjects ); err == nil {
409
- hasProjects = true
410
- }
411
-
412
- repo .mustOwner (e )
413
-
414
- numReleases , _ := GetReleaseCountByRepoID (repo .ID , FindReleasesOptions {IncludeDrafts : false , IncludeTags : true })
415
-
416
- return & api.Repository {
417
- ID : repo .ID ,
418
- // TODO use convert.ToUser(repo.Owner)
419
- Owner : & api.User {
420
- ID : repo .Owner .ID ,
421
- UserName : repo .Owner .Name ,
422
- FullName : repo .Owner .FullName ,
423
- Email : repo .Owner .GetEmail (),
424
- AvatarURL : repo .Owner .AvatarLink (),
425
- LastLogin : repo .Owner .LastLoginUnix .AsTime (),
426
- Created : repo .Owner .CreatedUnix .AsTime (),
427
- },
428
- Name : repo .Name ,
429
- FullName : repo .FullName (),
430
- Description : repo .Description ,
431
- Private : repo .IsPrivate ,
432
- Template : repo .IsTemplate ,
433
- Empty : repo .IsEmpty ,
434
- Archived : repo .IsArchived ,
435
- Size : int (repo .Size / 1024 ),
436
- Fork : repo .IsFork ,
437
- Parent : parent ,
438
- Mirror : repo .IsMirror ,
439
- HTMLURL : repo .HTMLURL (),
440
- SSHURL : cloneLink .SSH ,
441
- CloneURL : cloneLink .HTTPS ,
442
- Website : repo .Website ,
443
- Stars : repo .NumStars ,
444
- Forks : repo .NumForks ,
445
- Watchers : repo .NumWatches ,
446
- OpenIssues : repo .NumOpenIssues ,
447
- OpenPulls : repo .NumOpenPulls ,
448
- Releases : int (numReleases ),
449
- DefaultBranch : repo .DefaultBranch ,
450
- Created : repo .CreatedUnix .AsTime (),
451
- Updated : repo .UpdatedUnix .AsTime (),
452
- Permissions : permission ,
453
- HasIssues : hasIssues ,
454
- ExternalTracker : externalTracker ,
455
- InternalTracker : internalTracker ,
456
- HasUncyclo : hasUncyclo ,
457
- HasProjects : hasProjects ,
458
- ExternalUncyclo : externalUncyclo ,
459
- HasPullRequests : hasPullRequests ,
460
- IgnoreWhitespaceConflicts : ignoreWhitespaceConflicts ,
461
- AllowMerge : allowMerge ,
462
- AllowRebase : allowRebase ,
463
- AllowRebaseMerge : allowRebaseMerge ,
464
- AllowSquash : allowSquash ,
465
- AvatarURL : repo .avatarLink (e ),
466
- Internal : ! repo .IsPrivate && repo .Owner .Visibility == api .VisibleTypePrivate ,
467
- }
468
- }
469
-
470
336
func (repo * Repository ) getUnits (e Engine ) (err error ) {
471
337
if repo .Units != nil {
472
338
return nil
0 commit comments