@@ -58,6 +58,7 @@ type Repository struct {
58
58
Commit * git.Commit
59
59
Tag * git.Tag
60
60
GitRepo * git.Repository
61
+ RefName string
61
62
BranchName string
62
63
TagName string
63
64
TreePath string
@@ -190,9 +191,9 @@ func (r *Repository) BranchNameSubURL() string {
190
191
case r .IsViewBranch :
191
192
return "branch/" + r .BranchName
192
193
case r .IsViewTag :
193
- return "tag/" + r .BranchName
194
+ return "tag/" + r .TagName
194
195
case r .IsViewCommit :
195
- return "commit/" + r .BranchName
196
+ return "commit/" + r .CommitID
196
197
}
197
198
log .Error ("Unknown view type for repo: %v" , r )
198
199
return ""
@@ -562,8 +563,6 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
562
563
ctx .Data ["Branches" ] = brs
563
564
ctx .Data ["BranchesCount" ] = len (brs )
564
565
565
- ctx .Data ["TagName" ] = ctx .Repo .TagName
566
-
567
566
// If not branch selected, try default one.
568
567
// If default branch doesn't exists, fall back to some other branch.
569
568
if len (ctx .Repo .BranchName ) == 0 {
@@ -572,9 +571,9 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
572
571
} else if len (brs ) > 0 {
573
572
ctx .Repo .BranchName = brs [0 ]
574
573
}
574
+ ctx .Repo .RefName = ctx .Repo .BranchName
575
575
}
576
576
ctx .Data ["BranchName" ] = ctx .Repo .BranchName
577
- ctx .Data ["CommitID" ] = ctx .Repo .CommitID
578
577
579
578
// People who have push access or have forked repository can propose a new pull request.
580
579
canPush := ctx .Repo .CanWrite (models .UnitTypeCode ) || (ctx .IsSigned && ctx .User .HasForkedRepo (ctx .Repo .Repository .ID ))
@@ -759,7 +758,6 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
759
758
// Get default branch.
760
759
if len (ctx .Params ("*" )) == 0 {
761
760
refName = ctx .Repo .Repository .DefaultBranch
762
- ctx .Repo .BranchName = refName
763
761
if ! ctx .Repo .GitRepo .IsBranchExist (refName ) {
764
762
brs , _ , err := ctx .Repo .GitRepo .GetBranches (0 , 0 )
765
763
if err != nil {
@@ -773,6 +771,8 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
773
771
}
774
772
refName = brs [0 ]
775
773
}
774
+ ctx .Repo .RefName = refName
775
+ ctx .Repo .BranchName = refName
776
776
ctx .Repo .Commit , err = ctx .Repo .GitRepo .GetBranchCommit (refName )
777
777
if err != nil {
778
778
ctx .ServerError ("GetBranchCommit" , err )
@@ -783,9 +783,10 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
783
783
784
784
} else {
785
785
refName = getRefName (ctx , refType )
786
- ctx .Repo .BranchName = refName
786
+ ctx .Repo .RefName = refName
787
787
if refType .RefTypeIncludesBranches () && ctx .Repo .GitRepo .IsBranchExist (refName ) {
788
788
ctx .Repo .IsViewBranch = true
789
+ ctx .Repo .BranchName = refName
789
790
790
791
ctx .Repo .Commit , err = ctx .Repo .GitRepo .GetBranchCommit (refName )
791
792
if err != nil {
@@ -796,6 +797,8 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
796
797
797
798
} else if refType .RefTypeIncludesTags () && ctx .Repo .GitRepo .IsTagExist (refName ) {
798
799
ctx .Repo .IsViewTag = true
800
+ ctx .Repo .TagName = refName
801
+
799
802
ctx .Repo .Commit , err = ctx .Repo .GitRepo .GetTagCommit (refName )
800
803
if err != nil {
801
804
ctx .ServerError ("GetTagCommit" , err )
@@ -837,6 +840,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
837
840
838
841
ctx .Data ["BranchName" ] = ctx .Repo .BranchName
839
842
ctx .Data ["BranchNameSubURL" ] = ctx .Repo .BranchNameSubURL ()
843
+ ctx .Data ["TagName" ] = ctx .Repo .TagName
840
844
ctx .Data ["CommitID" ] = ctx .Repo .CommitID
841
845
ctx .Data ["TreePath" ] = ctx .Repo .TreePath
842
846
ctx .Data ["IsViewBranch" ] = ctx .Repo .IsViewBranch
0 commit comments