mirror of https://github.com/gogs/gogs.git
parent
934734a85a
commit
6002d72603
11
cmd/web.go
11
cmd/web.go
|
@ -632,14 +632,17 @@ func runWeb(ctx *cli.Context) error {
|
||||||
}, ignSignIn, context.RepoAssignment(), context.RepoRef())
|
}, ignSignIn, context.RepoAssignment(), context.RepoRef())
|
||||||
|
|
||||||
m.Group("/:username", func() {
|
m.Group("/:username", func() {
|
||||||
m.Group("/:reponame", func() {
|
m.Group("", func() {
|
||||||
m.Get("", repo.Home)
|
m.Get("/:reponame", repo.Home)
|
||||||
m.Get("\\.git$", repo.Home)
|
|
||||||
}, ignSignIn, context.RepoAssignment(true), context.RepoRef())
|
}, ignSignIn, context.RepoAssignment(true), context.RepoRef())
|
||||||
|
|
||||||
m.Group("/:reponame", func() {
|
m.Group("/:reponame", func() {
|
||||||
m.Head("/tasks/trigger", repo.TriggerTask)
|
m.Head("/tasks/trigger", repo.TriggerTask)
|
||||||
m.Route("\\.git/*", "GET,POST", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP)
|
})
|
||||||
|
// Use the regexp to match the repository name validation
|
||||||
|
m.Group("/:reponame([\\d\\w-_\\.]+\\.git$)", func() {
|
||||||
|
m.Get("", ignSignIn, context.RepoAssignment(true), context.RepoRef(), repo.Home)
|
||||||
|
m.Route("/*", "GET,POST", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// ***** END: Repository *****
|
// ***** END: Repository *****
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.9.161.0220"
|
const APP_VER = "0.9.162.0220"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setting.AppVer = APP_VER
|
setting.AppVer = APP_VER
|
||||||
|
|
|
@ -146,18 +146,18 @@ func RepoAssignment(args ...bool) macaron.Handler {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
userName := ctx.Params(":username")
|
ownerName := ctx.Params(":username")
|
||||||
repoName := ctx.Params(":reponame")
|
repoName := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
|
||||||
refName := ctx.Params(":branchname")
|
refName := ctx.Params(":branchname")
|
||||||
if len(refName) == 0 {
|
if len(refName) == 0 {
|
||||||
refName = ctx.Params(":path")
|
refName = ctx.Params(":path")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user is the same as the repository owner
|
// Check if the user is the same as the repository owner
|
||||||
if ctx.IsSigned && ctx.User.LowerName == strings.ToLower(userName) {
|
if ctx.IsSigned && ctx.User.LowerName == strings.ToLower(ownerName) {
|
||||||
owner = ctx.User
|
owner = ctx.User
|
||||||
} else {
|
} else {
|
||||||
owner, err = models.GetUserByName(userName)
|
owner, err = models.GetUserByName(ownerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrUserNotExist(err) {
|
if models.IsErrUserNotExist(err) {
|
||||||
if ctx.Query("go-get") == "1" {
|
if ctx.Query("go-get") == "1" {
|
||||||
|
@ -230,9 +230,9 @@ func RepoAssignment(args ...bool) macaron.Handler {
|
||||||
ctx.Data["RepoName"] = ctx.Repo.Repository.Name
|
ctx.Data["RepoName"] = ctx.Repo.Repository.Name
|
||||||
ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare
|
ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare
|
||||||
|
|
||||||
gitRepo, err := git.OpenRepository(models.RepoPath(userName, repoName))
|
gitRepo, err := git.OpenRepository(models.RepoPath(ownerName, repoName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "RepoAssignment Invalid repo "+models.RepoPath(userName, repoName), err)
|
ctx.Handle(500, "RepoAssignment Invalid repo "+models.RepoPath(ownerName, repoName), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Repo.GitRepo = gitRepo
|
ctx.Repo.GitRepo = gitRepo
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.9.161.0220
|
0.9.162.0220
|
Loading…
Reference in New Issue