Bug fix
This commit is contained in:
parent
6ca32ef44f
commit
e656609b0d
|
@ -23,7 +23,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// "### autogenerated by gitgos, DO NOT EDIT\n"
|
// "### 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 (
|
var (
|
||||||
|
|
|
@ -223,6 +223,17 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
||||||
return err
|
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.
|
// Initialize repository according to user's choice.
|
||||||
fileName := map[string]string{}
|
fileName := map[string]string{}
|
||||||
if initReadme {
|
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.
|
// Apply changes and commit.
|
||||||
if err := initRepoCommit(tmpDir, user.NewGitSig()); err != nil {
|
if err := initRepoCommit(tmpDir, user.NewGitSig()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,15 +22,18 @@ func Branches(ctx *middleware.Context, params martini.Params) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["Username"] = params["username"]
|
|
||||||
ctx.Data["Reponame"] = params["reponame"]
|
|
||||||
|
|
||||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(200, "repo.Branches", err)
|
ctx.Handle(200, "repo.Branches", err)
|
||||||
return
|
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["Branchname"] = brs[0]
|
||||||
ctx.Data["Branches"] = brs
|
ctx.Data["Branches"] = brs
|
||||||
ctx.Data["IsRepoToolbarBranches"] = true
|
ctx.Data["IsRepoToolbarBranches"] = true
|
||||||
|
@ -49,25 +53,32 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
||||||
// Get tree path
|
// Get tree path
|
||||||
treename := params["_1"]
|
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.
|
// Directory and file list.
|
||||||
files, err := models.GetReposFiles(params["username"], params["reponame"],
|
files, err := models.GetReposFiles(params["username"], params["reponame"],
|
||||||
params["branchname"], treename)
|
params["branchname"], treename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(200, "repo.Single(GetReposFiles)", err)
|
log.Error("repo.Single(GetReposFiles): %v", err)
|
||||||
|
ctx.Render.Error(404)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["Username"] = params["username"]
|
ctx.Data["Username"] = params["username"]
|
||||||
ctx.Data["Reponame"] = params["reponame"]
|
ctx.Data["Reponame"] = params["reponame"]
|
||||||
ctx.Data["Branchname"] = params["branchname"]
|
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
|
var treenames []string
|
||||||
Paths := make([]string, 0)
|
Paths := make([]string, 0)
|
||||||
|
|
||||||
|
@ -81,7 +92,8 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
||||||
// Get latest commit according username and repo name
|
// Get latest commit according username and repo name
|
||||||
commit, err := models.GetLastestCommit(params["username"], params["reponame"])
|
commit, err := models.GetLastestCommit(params["username"], params["reponame"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(200, "repo.Single(GetLastestCommit)", err)
|
log.Error("repo.Single(GetLastestCommit): %v", err)
|
||||||
|
ctx.Render.Error(404)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["LatestCommit"] = commit
|
ctx.Data["LatestCommit"] = commit
|
||||||
|
@ -126,6 +138,18 @@ func Setting(ctx *middleware.Context, params martini.Params) {
|
||||||
return
|
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
|
var title string
|
||||||
if t, ok := ctx.Data["Title"].(string); ok {
|
if t, ok := ctx.Data["Title"].(string); ok {
|
||||||
title = t
|
title = t
|
||||||
|
@ -137,6 +161,15 @@ func Setting(ctx *middleware.Context, params martini.Params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Commits(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
|
ctx.Data["IsRepoToolbarCommits"] = true
|
||||||
commits, err := models.GetCommits(params["username"],
|
commits, err := models.GetCommits(params["username"],
|
||||||
params["reponame"], params["branchname"])
|
params["reponame"], params["branchname"])
|
||||||
|
|
3
serve.go
3
serve.go
|
@ -149,8 +149,7 @@ func runServ(*cli.Context) {
|
||||||
gitcmd.Stdin = os.Stdin
|
gitcmd.Stdin = os.Stdin
|
||||||
gitcmd.Stderr = os.Stderr
|
gitcmd.Stderr = os.Stderr
|
||||||
|
|
||||||
err = gitcmd.Run()
|
if err = gitcmd.Run(); err != nil {
|
||||||
if err != nil {
|
|
||||||
println("execute command error:", err.Error())
|
println("execute command error:", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h3><i class="fa fa-book fa-lg"></i><a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / {{.Repository.Name}}</h3>
|
<h3><i class="fa fa-book fa-lg"></i><a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / {{.Repository.Name}}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
{{if not .IsBareRepo}}
|
||||||
<div class="col-md-6 actions text-right">
|
<div class="col-md-6 actions text-right">
|
||||||
<div class="btn-group" id="gogs-repo-clone">
|
<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"><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>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -36,6 +37,7 @@
|
||||||
<button type="button" class="btn btn-default"><i class="fa fa-code-fork"></i>Fork {{.Repository.NumForks}}</button>
|
<button type="button" class="btn btn-default"><i class="fa fa-code-fork"></i>Fork {{.Repository.NumForks}}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -4,6 +4,9 @@
|
||||||
{{template "repo/toolbar" .}}
|
{{template "repo/toolbar" .}}
|
||||||
<div id="gogs-body" class="container">
|
<div id="gogs-body" class="container">
|
||||||
<div id="gogs-source">
|
<div id="gogs-source">
|
||||||
|
{{if .IsBareRepo}}
|
||||||
|
Need to fill in some guide.
|
||||||
|
{{else}}
|
||||||
<div class="source-toolbar">
|
<div class="source-toolbar">
|
||||||
{{ $username := .Username}}
|
{{ $username := .Username}}
|
||||||
{{ $reponame := .Reponame}}
|
{{ $reponame := .Reponame}}
|
||||||
|
@ -36,6 +39,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel panel-default info-box">
|
<div class="panel panel-default info-box">
|
||||||
<div class="panel-heading info-head">
|
<div class="panel-heading info-head">
|
||||||
<a href="/{{$username}}/{{$reponame}}/commit/{{.LatestCommit.SHA}}">{{.LatestCommit.Message}}</a>
|
<a href="/{{$username}}/{{$reponame}}/commit/{{.LatestCommit.SHA}}">{{.LatestCommit.Message}}</a>
|
||||||
|
@ -95,6 +99,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{template "base/footer" .}}
|
{{template "base/footer" .}}
|
|
@ -4,6 +4,7 @@
|
||||||
<div class="collapse navbar-collapse">
|
<div class="collapse navbar-collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li class="{{if .IsRepoToolbarSource}}active{{end}}"><a href="/{{.RepositoryLink}}">Source</a></li>
|
<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 .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 .IsRepoToolbarBranches}}active{{end}}"><a href="/{{.RepositoryLink}}/branches">Branches</a></li>
|
||||||
<li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="/{{.RepositoryLink}}/pulls">Pull Requests</a></li>
|
<li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="/{{.RepositoryLink}}/pulls">Pull Requests</a></li>
|
||||||
|
@ -16,7 +17,9 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
{{end}}
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
{{if not .IsBareRepo}}
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Statistic <b class="caret"></b></a>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Statistic <b class="caret"></b></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
@ -24,7 +27,7 @@
|
||||||
<li><a href="#">Pulse</a></li>
|
<li><a href="#">Pulse</a></li>
|
||||||
<li><a href="#">Network</a></li>
|
<li><a href="#">Network</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>{{if .IsRepositoryOwner}}
|
</li>{{end}}{{if .IsRepositoryOwner}}
|
||||||
<li class="{{if .IsRepoToolbarSetting}}active{{end}}"><a href="/{{.RepositoryLink}}/settings">Settings</a>
|
<li class="{{if .IsRepoToolbarSetting}}active{{end}}"><a href="/{{.RepositoryLink}}/settings">Settings</a>
|
||||||
</li>{{end}}
|
</li>{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue