@@ -391,34 +391,36 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
391
391
if rootRepo != nil &&
392
392
rootRepo .ID != headRepo .ID &&
393
393
rootRepo .ID != baseRepo .ID {
394
- perm , branches , err := getBranchesForRepo (ctx .User , rootRepo )
394
+ perm , branches , tags , err := getBranchesAndTagsForRepo (ctx .User , rootRepo )
395
395
if err != nil {
396
396
ctx .ServerError ("GetBranchesForRepo" , err )
397
397
return nil , nil , nil , nil , "" , ""
398
398
}
399
399
if perm {
400
400
ctx .Data ["RootRepo" ] = rootRepo
401
401
ctx .Data ["RootRepoBranches" ] = branches
402
+ ctx .Data ["RootRepoTags" ] = tags
402
403
}
403
404
}
404
405
405
406
// If we have a ownForkRepo and it's different from:
406
407
// 1. The computed base
407
- // 2. The computed hea
408
+ // 2. The computed head
408
409
// 3. The rootRepo (if we have one)
409
410
// then get the branches from it.
410
411
if ownForkRepo != nil &&
411
412
ownForkRepo .ID != headRepo .ID &&
412
413
ownForkRepo .ID != baseRepo .ID &&
413
414
(rootRepo == nil || ownForkRepo .ID != rootRepo .ID ) {
414
- perm , branches , err := getBranchesForRepo (ctx .User , ownForkRepo )
415
+ perm , branches , tags , err := getBranchesAndTagsForRepo (ctx .User , ownForkRepo )
415
416
if err != nil {
416
417
ctx .ServerError ("GetBranchesForRepo" , err )
417
418
return nil , nil , nil , nil , "" , ""
418
419
}
419
420
if perm {
420
421
ctx .Data ["OwnForkRepo" ] = ownForkRepo
421
422
ctx .Data ["OwnForkRepoBranches" ] = branches
423
+ ctx .Data ["OwnForkRepoTags" ] = tags
422
424
}
423
425
}
424
426
@@ -572,25 +574,29 @@ func PrepareCompareDiff(
572
574
return false
573
575
}
574
576
575
- func getBranchesForRepo (user * models.User , repo * models.Repository ) (bool , []string , error ) {
577
+ func getBranchesAndTagsForRepo (user * models.User , repo * models.Repository ) (bool , [] string , []string , error ) {
576
578
perm , err := models .GetUserRepoPermission (repo , user )
577
579
if err != nil {
578
- return false , nil , err
580
+ return false , nil , nil , err
579
581
}
580
582
if ! perm .CanRead (models .UnitTypeCode ) {
581
- return false , nil , nil
583
+ return false , nil , nil , nil
582
584
}
583
585
gitRepo , err := git .OpenRepository (repo .RepoPath ())
584
586
if err != nil {
585
- return false , nil , err
587
+ return false , nil , nil , err
586
588
}
587
589
defer gitRepo .Close ()
588
590
589
591
branches , _ , err := gitRepo .GetBranches (0 , 0 )
590
592
if err != nil {
591
- return false , nil , err
593
+ return false , nil , nil , err
592
594
}
593
- return true , branches , nil
595
+ tags , err := gitRepo .GetTags ()
596
+ if err != nil {
597
+ return false , nil , nil , err
598
+ }
599
+ return true , branches , tags , nil
594
600
}
595
601
596
602
// CompareDiff show different from one commit to another commit
@@ -608,14 +614,29 @@ func CompareDiff(ctx *context.Context) {
608
614
return
609
615
}
610
616
611
- if ctx . Data [ "PageIsComparePull" ] == true {
612
- headBranches , _ , err := headGitRepo . GetBranches ( 0 , 0 )
613
- if err != nil {
614
- ctx .ServerError ("GetBranches " , err )
615
- return
616
- }
617
- ctx .Data ["HeadBranches " ] = headBranches
617
+ baseGitRepo := ctx . Repo . GitRepo
618
+ baseTags , err := baseGitRepo . GetTags ( )
619
+ if err != nil {
620
+ ctx .ServerError ("GetTags " , err )
621
+ return
622
+ }
623
+ ctx .Data ["Tags " ] = baseTags
618
624
625
+ headBranches , _ , err := headGitRepo .GetBranches (0 , 0 )
626
+ if err != nil {
627
+ ctx .ServerError ("GetBranches" , err )
628
+ return
629
+ }
630
+ ctx .Data ["HeadBranches" ] = headBranches
631
+
632
+ headTags , err := headGitRepo .GetTags ()
633
+ if err != nil {
634
+ ctx .ServerError ("GetTags" , err )
635
+ return
636
+ }
637
+ ctx .Data ["HeadTags" ] = headTags
638
+
639
+ if ctx .Data ["PageIsComparePull" ] == true {
619
640
pr , err := models .GetUnmergedPullRequest (headRepo .ID , ctx .Repo .Repository .ID , headBranch , baseBranch )
620
641
if err != nil {
621
642
if ! models .IsErrPullRequestNotExist (err ) {
0 commit comments