@@ -391,34 +391,36 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
391391 if rootRepo != nil &&
392392 rootRepo .ID != headRepo .ID &&
393393 rootRepo .ID != baseRepo .ID {
394- perm , branches , err := getBranchesForRepo (ctx .User , rootRepo )
394+ perm , branches , tags , err := getBranchesAndTagsForRepo (ctx .User , rootRepo )
395395 if err != nil {
396396 ctx .ServerError ("GetBranchesForRepo" , err )
397397 return nil , nil , nil , nil , "" , ""
398398 }
399399 if perm {
400400 ctx .Data ["RootRepo" ] = rootRepo
401401 ctx .Data ["RootRepoBranches" ] = branches
402+ ctx .Data ["RootRepoTags" ] = tags
402403 }
403404 }
404405
405406 // If we have a ownForkRepo and it's different from:
406407 // 1. The computed base
407- // 2. The computed hea
408+ // 2. The computed head
408409 // 3. The rootRepo (if we have one)
409410 // then get the branches from it.
410411 if ownForkRepo != nil &&
411412 ownForkRepo .ID != headRepo .ID &&
412413 ownForkRepo .ID != baseRepo .ID &&
413414 (rootRepo == nil || ownForkRepo .ID != rootRepo .ID ) {
414- perm , branches , err := getBranchesForRepo (ctx .User , ownForkRepo )
415+ perm , branches , tags , err := getBranchesAndTagsForRepo (ctx .User , ownForkRepo )
415416 if err != nil {
416417 ctx .ServerError ("GetBranchesForRepo" , err )
417418 return nil , nil , nil , nil , "" , ""
418419 }
419420 if perm {
420421 ctx .Data ["OwnForkRepo" ] = ownForkRepo
421422 ctx .Data ["OwnForkRepoBranches" ] = branches
423+ ctx .Data ["OwnForkRepoTags" ] = tags
422424 }
423425 }
424426
@@ -572,25 +574,29 @@ func PrepareCompareDiff(
572574 return false
573575}
574576
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 ) {
576578 perm , err := models .GetUserRepoPermission (repo , user )
577579 if err != nil {
578- return false , nil , err
580+ return false , nil , nil , err
579581 }
580582 if ! perm .CanRead (models .UnitTypeCode ) {
581- return false , nil , nil
583+ return false , nil , nil , nil
582584 }
583585 gitRepo , err := git .OpenRepository (repo .RepoPath ())
584586 if err != nil {
585- return false , nil , err
587+ return false , nil , nil , err
586588 }
587589 defer gitRepo .Close ()
588590
589591 branches , _ , err := gitRepo .GetBranches (0 , 0 )
590592 if err != nil {
591- return false , nil , err
593+ return false , nil , nil , err
592594 }
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
594600}
595601
596602// CompareDiff show different from one commit to another commit
@@ -608,14 +614,29 @@ func CompareDiff(ctx *context.Context) {
608614 return
609615 }
610616
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
618624
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 {
619640 pr , err := models .GetUnmergedPullRequest (headRepo .ID , ctx .Repo .Repository .ID , headBranch , baseBranch )
620641 if err != nil {
621642 if ! models .IsErrPullRequestNotExist (err ) {
0 commit comments