mirror of https://github.com/go-gitea/gitea.git
Bug fix
This commit is contained in:
parent
6ca32ef44f
commit
e656609b0d
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
const (
|
||||
// "### autogenerated by gitgos, DO NOT EDIT\n"
|
||||
TPL_PUBLICK_KEY = `command="%s serv key-%d",no-port-forwarding, no-X11-forwarding,no-agent-forwarding,no-pty %s`
|
||||
TPL_PUBLICK_KEY = `command="%s serv key-%d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s`
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -223,6 +223,17 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
|||
return err
|
||||
}
|
||||
|
||||
// hook/post-update
|
||||
pu, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-update"), os.O_CREATE|os.O_WRONLY, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer pu.Close()
|
||||
// TODO: Windows .bat
|
||||
if _, err = pu.WriteString(fmt.Sprintf("#!/usr/bin/env bash\n%s update\n", appPath)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Initialize repository according to user's choice.
|
||||
fileName := map[string]string{}
|
||||
if initReadme {
|
||||
|
@ -275,11 +286,14 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
|||
}
|
||||
}
|
||||
|
||||
if len(fileName) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Apply changes and commit.
|
||||
if err := initRepoCommit(tmpDir, user.NewGitSig()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
|
@ -21,15 +22,18 @@ func Branches(ctx *middleware.Context, params martini.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Data["Username"] = params["username"]
|
||||
ctx.Data["Reponame"] = params["reponame"]
|
||||
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Branches", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Render.Error(404)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Username"] = params["username"]
|
||||
ctx.Data["Reponame"] = params["reponame"]
|
||||
|
||||
ctx.Data["Branchname"] = brs[0]
|
||||
ctx.Data["Branches"] = brs
|
||||
ctx.Data["IsRepoToolbarBranches"] = true
|
||||
|
@ -49,25 +53,32 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
|||
// Get tree path
|
||||
treename := params["_1"]
|
||||
|
||||
// Branches.
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
log.Error("repo.Single(GetBranches): %v", err)
|
||||
ctx.Render.Error(404)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Data["IsBareRepo"] = true
|
||||
ctx.Render.HTML(200, "repo/single", ctx.Data)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Branches"] = brs
|
||||
|
||||
// Directory and file list.
|
||||
files, err := models.GetReposFiles(params["username"], params["reponame"],
|
||||
params["branchname"], treename)
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Single(GetReposFiles)", err)
|
||||
log.Error("repo.Single(GetReposFiles): %v", err)
|
||||
ctx.Render.Error(404)
|
||||
return
|
||||
}
|
||||
ctx.Data["Username"] = params["username"]
|
||||
ctx.Data["Reponame"] = params["reponame"]
|
||||
ctx.Data["Branchname"] = params["branchname"]
|
||||
|
||||
// Branches.
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Single(GetBranches)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Branches"] = brs
|
||||
|
||||
var treenames []string
|
||||
Paths := make([]string, 0)
|
||||
|
||||
|
@ -81,7 +92,8 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
|||
// Get latest commit according username and repo name
|
||||
commit, err := models.GetLastestCommit(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Single(GetLastestCommit)", err)
|
||||
log.Error("repo.Single(GetLastestCommit): %v", err)
|
||||
ctx.Render.Error(404)
|
||||
return
|
||||
}
|
||||
ctx.Data["LatestCommit"] = commit
|
||||
|
@ -126,6 +138,18 @@ func Setting(ctx *middleware.Context, params martini.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
// Branches.
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
log.Error("repo.Setting(GetBranches): %v", err)
|
||||
ctx.Render.Error(404)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Data["IsBareRepo"] = true
|
||||
ctx.Render.HTML(200, "repo/setting", ctx.Data)
|
||||
return
|
||||
}
|
||||
|
||||
var title string
|
||||
if t, ok := ctx.Data["Title"].(string); ok {
|
||||
title = t
|
||||
|
@ -137,6 +161,15 @@ func Setting(ctx *middleware.Context, params martini.Params) {
|
|||
}
|
||||
|
||||
func Commits(ctx *middleware.Context, params martini.Params) {
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Commits", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Render.Error(404)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
commits, err := models.GetCommits(params["username"],
|
||||
params["reponame"], params["branchname"])
|
||||
|
|
3
serve.go
3
serve.go
|
@ -149,8 +149,7 @@ func runServ(*cli.Context) {
|
|||
gitcmd.Stdin = os.Stdin
|
||||
gitcmd.Stderr = os.Stderr
|
||||
|
||||
err = gitcmd.Run()
|
||||
if err != nil {
|
||||
if err = gitcmd.Run(); err != nil {
|
||||
println("execute command error:", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
<div class="col-md-6">
|
||||
<h3><i class="fa fa-book fa-lg"></i><a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / {{.Repository.Name}}</h3>
|
||||
</div>
|
||||
{{if not .IsBareRepo}}
|
||||
<div class="col-md-6 actions text-right">
|
||||
<div class="btn-group" id="gogs-repo-clone">
|
||||
<button type="button" class="btn btn-default"><i class="fa fa-download"></i>Clone</button>
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-container="body" data-toggle="popover" data-placement="bottom" data-content="<label>SSH:</label><div class='input-group'><input type='text' class='form-control' value='git@{{AppDomain}}:{{.Owner.Name}}/{{.Repository.Name}}.git'></div>" data-html="1">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-container="body" data-toggle="popover" data-placement="bottom" data-content="<label>SSH:</label><div class='input-group'><input type='text' class='form-control' value='git@{{AppDomain}}:{{.Owner.LowerName}}/{{.Repository.Name}}.git'></div>" data-html="1">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -36,6 +37,7 @@
|
|||
<button type="button" class="btn btn-default"><i class="fa fa-code-fork"></i>Fork {{.Repository.NumForks}}</button>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -4,6 +4,9 @@
|
|||
{{template "repo/toolbar" .}}
|
||||
<div id="gogs-body" class="container">
|
||||
<div id="gogs-source">
|
||||
{{if .IsBareRepo}}
|
||||
Need to fill in some guide.
|
||||
{{else}}
|
||||
<div class="source-toolbar">
|
||||
{{ $username := .Username}}
|
||||
{{ $reponame := .Reponame}}
|
||||
|
@ -36,6 +39,7 @@
|
|||
{{end}}
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default info-box">
|
||||
<div class="panel-heading info-head">
|
||||
<a href="/{{$username}}/{{$reponame}}/commit/{{.LatestCommit.SHA}}">{{.LatestCommit.Message}}</a>
|
||||
|
@ -95,6 +99,7 @@
|
|||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
|
@ -4,6 +4,7 @@
|
|||
<div class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="{{if .IsRepoToolbarSource}}active{{end}}"><a href="/{{.RepositoryLink}}">Source</a></li>
|
||||
{{if not .IsBareRepo}}
|
||||
<li class="{{if .IsRepoToolbarCommits}}active{{end}}"><a href="/{{.RepositoryLink}}/commits/{{.Branchname}}">Commits</a></li>
|
||||
<li class="{{if .IsRepoToolbarBranches}}active{{end}}"><a href="/{{.RepositoryLink}}/branches">Branches</a></li>
|
||||
<li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="/{{.RepositoryLink}}/pulls">Pull Requests</a></li>
|
||||
|
@ -16,7 +17,9 @@
|
|||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
{{end}}
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{{if not .IsBareRepo}}
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Statistic <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
@ -24,7 +27,7 @@
|
|||
<li><a href="#">Pulse</a></li>
|
||||
<li><a href="#">Network</a></li>
|
||||
</ul>
|
||||
</li>{{if .IsRepositoryOwner}}
|
||||
</li>{{end}}{{if .IsRepositoryOwner}}
|
||||
<li class="{{if .IsRepoToolbarSetting}}active{{end}}"><a href="/{{.RepositoryLink}}/settings">Settings</a>
|
||||
</li>{{end}}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue