|
|
@ -249,9 +249,13 @@ func RepoAssignment(pages ...bool) macaron.Handler { |
|
|
|
c.Data["TagName"] = c.Repo.TagName |
|
|
|
c.Data["TagName"] = c.Repo.TagName |
|
|
|
brs, err := c.Repo.GitRepo.GetBranches() |
|
|
|
brs, err := c.Repo.GitRepo.GetBranches() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
c.ServerError("GetBranches", err) |
|
|
|
brs = make([]string, 0) |
|
|
|
|
|
|
|
_, err = c.Repo.GitRepo.GetTags() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
c.Handle(500, "GetBranches|GetTags", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
c.Data["Branches"] = brs |
|
|
|
c.Data["Branches"] = brs |
|
|
|
c.Data["BrancheCount"] = len(brs) |
|
|
|
c.Data["BrancheCount"] = len(brs) |
|
|
|
|
|
|
|
|
|
|
@ -296,22 +300,35 @@ func RepoRef() macaron.Handler { |
|
|
|
|
|
|
|
|
|
|
|
// Get default branch.
|
|
|
|
// Get default branch.
|
|
|
|
if len(c.Params("*")) == 0 { |
|
|
|
if len(c.Params("*")) == 0 { |
|
|
|
|
|
|
|
isBranch := true |
|
|
|
refName = c.Repo.Repository.DefaultBranch |
|
|
|
refName = c.Repo.Repository.DefaultBranch |
|
|
|
if !c.Repo.GitRepo.IsBranchExist(refName) { |
|
|
|
if !c.Repo.GitRepo.IsBranchExist(refName) { |
|
|
|
brs, err := c.Repo.GitRepo.GetBranches() |
|
|
|
brs, err := c.Repo.GitRepo.GetBranches() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
c.Handle(500, "GetBranches", err) |
|
|
|
brs, err = c.Repo.GitRepo.GetTags() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
c.Handle(500, "GetBranches|GetTags", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
isBranch = false |
|
|
|
|
|
|
|
} |
|
|
|
refName = brs[0] |
|
|
|
refName = brs[0] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if isBranch { |
|
|
|
c.Repo.Commit, err = c.Repo.GitRepo.GetBranchCommit(refName) |
|
|
|
c.Repo.Commit, err = c.Repo.GitRepo.GetBranchCommit(refName) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
c.Repo.Commit, err = c.Repo.GitRepo.GetTagCommit(refName) |
|
|
|
|
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
c.Handle(500, "GetBranchCommit", err) |
|
|
|
c.Handle(500, "GetBranchCommit", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
c.Repo.CommitID = c.Repo.Commit.ID.String() |
|
|
|
c.Repo.CommitID = c.Repo.Commit.ID.String() |
|
|
|
|
|
|
|
if (isBranch) { |
|
|
|
c.Repo.IsViewBranch = true |
|
|
|
c.Repo.IsViewBranch = true |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
c.Repo.IsViewTag = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
hasMatched := false |
|
|
|
hasMatched := false |
|
|
|