Browse Source

Add view by tag support

pull/79/head
Unknown 11 years ago
parent
commit
67426534ef
  1. 4
      README.md
  2. 6
      README_ZH.md
  3. 35
      modules/middleware/repo.go

4
README.md

@ -24,7 +24,7 @@ More importantly, Gogs only needs one binary to setup your own project hosting o
## Overview ## Overview
- Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, known issues, change log and road map. - Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, known issues, and change log.
- See [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team. - See [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team.
- Try it before anything? Do it [online](http://try.gogits.org/Unknown/gogs) or go down to **Installation -> Install from binary** section! - Try it before anything? Do it [online](http://try.gogits.org/Unknown/gogs) or go down to **Installation -> Install from binary** section!
- Having troubles? Get help from [Troubleshooting](https://github.com/gogits/gogs/wiki/Troubleshooting). - Having troubles? Get help from [Troubleshooting](https://github.com/gogits/gogs/wiki/Troubleshooting).
@ -64,7 +64,7 @@ There are 3 ways to install Gogs:
## Contributors ## Contributors
This project was launched by [Unknown](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei), [slene](https://github.com/slene) and [skyblue](https://github.com/shxsun) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors. This project was launched by [Unknown](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei), [slene](https://github.com/slene) and [codeskyblue](https://github.com/codeskyblue) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors.
## License ## License

6
README_ZH.md

@ -15,7 +15,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
## 项目概览 ## 项目概览
- 有关项目设计、已知问题、变更日志和路线图,请通过 [Wiki](https://github.com/gogits/gogs/wiki) 查看。 - 有关项目设计、已知问题和变更日志,请通过 [Wiki](https://github.com/gogits/gogs/wiki) 查看。
- 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。 - 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。
- 想要先睹为快?通过 [在线体验](http://try.gogits.org/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。 - 想要先睹为快?通过 [在线体验](http://try.gogits.org/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。
- 使用过程中遇到问题?尝试从 [故障排查](https://github.com/gogits/gogs/wiki/Troubleshooting) 页面获取帮助。 - 使用过程中遇到问题?尝试从 [故障排查](https://github.com/gogits/gogs/wiki/Troubleshooting) 页面获取帮助。
@ -30,7 +30,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
- Gravatar 以及缓存支持 - Gravatar 以及缓存支持
- 邮件服务(注册、Issue) - 邮件服务(注册、Issue)
- 管理员面板 - 管理员面板
- 支持 MySQL、PostgreSQL 以及 SQLite3 - 支持 MySQL、PostgreSQL 以及 SQLite3 数据库
- 社交帐号登录(GitHub、Google、QQ、微博) - 社交帐号登录(GitHub、Google、QQ、微博)
## 安装部署 ## 安装部署
@ -55,7 +55,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
## 贡献成员 ## 贡献成员
本项目最初由 [Unknown](https://github.com/Unknwon) 和 [lunny](https://github.com/lunny) 发起,随后 [fuxiaohei](https://github.com/fuxiaohei)、[slene](https://github.com/slene) 以及 [skyblue](https://github.com/shxsun) 加入到开发团队。您可以通过查看 [贡献者页面](https://github.com/gogits/gogs/graphs/contributors) 获取完整的贡献者列表。 本项目最初由 [Unknown](https://github.com/Unknwon) 和 [lunny](https://github.com/lunny) 发起,随后 [fuxiaohei](https://github.com/fuxiaohei)、[slene](https://github.com/slene) 以及 [codeskyblue](https://github.com/codeskyblue) 加入到开发团队。您可以通过查看 [贡献者页面](https://github.com/gogits/gogs/graphs/contributors) 获取完整的贡献者列表。
## 授权许可 ## 授权许可

35
modules/middleware/repo.go

@ -40,7 +40,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
userName := params["username"] userName := params["username"]
repoName := params["reponame"] repoName := params["reponame"]
branchName := params["branchname"] refName := params["branchname"]
// get repository owner // get repository owner
ctx.Repo.IsOwner = ctx.IsSigned && ctx.User.LowerName == strings.ToLower(userName) ctx.Repo.IsOwner = ctx.IsSigned && ctx.User.LowerName == strings.ToLower(userName)
@ -149,26 +149,35 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
// when repo is bare, not valid branch // when repo is bare, not valid branch
if !ctx.Repo.Repository.IsBare && validBranch { if !ctx.Repo.Repository.IsBare && validBranch {
detect: detect:
if len(branchName) > 0 { if len(refName) > 0 {
// TODO check tag if gitRepo.IsBranchExist(refName) {
if gitRepo.IsBranchExist(branchName) {
ctx.Repo.IsBranch = true ctx.Repo.IsBranch = true
ctx.Repo.BranchName = branchName ctx.Repo.BranchName = refName
ctx.Repo.Commit, err = gitRepo.GetCommitOfBranch(branchName) ctx.Repo.Commit, err = gitRepo.GetCommitOfBranch(refName)
if err != nil { if err != nil {
ctx.Handle(404, "RepoAssignment invalid branch", nil) ctx.Handle(404, "RepoAssignment invalid branch", nil)
return return
} }
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
} else if gitRepo.IsTagExist(refName) {
ctx.Repo.IsBranch = true
ctx.Repo.BranchName = refName
ctx.Repo.Commit, err = gitRepo.GetCommitOfTag(refName)
if err != nil {
ctx.Handle(404, "RepoAssignment invalid tag", nil)
return
}
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String() ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
} else if len(branchName) == 40 { } else if len(refName) == 40 {
ctx.Repo.IsCommit = true ctx.Repo.IsCommit = true
ctx.Repo.CommitId = branchName ctx.Repo.CommitId = refName
ctx.Repo.BranchName = branchName ctx.Repo.BranchName = refName
ctx.Repo.Commit, err = gitRepo.GetCommit(branchName) ctx.Repo.Commit, err = gitRepo.GetCommit(refName)
if err != nil { if err != nil {
ctx.Handle(404, "RepoAssignment invalid commit", nil) ctx.Handle(404, "RepoAssignment invalid commit", nil)
return return
@ -179,9 +188,9 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
} }
} else { } else {
branchName = ctx.Repo.Repository.DefaultBranch refName = ctx.Repo.Repository.DefaultBranch
if len(branchName) == 0 { if len(refName) == 0 {
branchName = "master" refName = "master"
} }
goto detect goto detect
} }

Loading…
Cancel
Save