Browse Source

Fix formatting

pull/2439/head
Faraz Fazli 9 years ago
parent
commit
0139881b00
  1. 10
      cmd/dump.go
  2. 2
      cmd/web.go
  3. 100
      models/git_diff_test.go
  4. 2
      models/wiki.go
  5. 1603
      modules/bindata/bindata.go
  6. 2
      modules/user/user.go
  7. 4
      routers/admin/orgs.go
  8. 2
      routers/repo/view.go

10
cmd/dump.go

@ -68,21 +68,21 @@ func runDump(ctx *cli.Context) {
log.Fatalf("Fail to create %s: %v", fileName, err) log.Fatalf("Fail to create %s: %v", fileName, err)
} }
if err := z.AddFile("gogs-repo.zip", reposDump); err !=nil { if err := z.AddFile("gogs-repo.zip", reposDump); err != nil {
log.Fatalf("Fail to include gogs-repo.zip: %v", err) log.Fatalf("Fail to include gogs-repo.zip: %v", err)
} }
if err := z.AddFile("gogs-db.sql", dbDump); err !=nil { if err := z.AddFile("gogs-db.sql", dbDump); err != nil {
log.Fatalf("Fail to include gogs-db.sql: %v", err) log.Fatalf("Fail to include gogs-db.sql: %v", err)
} }
customDir, err := os.Stat(setting.CustomPath) customDir, err := os.Stat(setting.CustomPath)
if err == nil && customDir.IsDir() { if err == nil && customDir.IsDir() {
if err := z.AddDir("custom", setting.CustomPath); err !=nil { if err := z.AddDir("custom", setting.CustomPath); err != nil {
log.Fatalf("Fail to include custom: %v", err) log.Fatalf("Fail to include custom: %v", err)
} }
} else { } else {
log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath) log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath)
} }
if err := z.AddDir("log", setting.LogRootPath); err !=nil { if err := z.AddDir("log", setting.LogRootPath); err != nil {
log.Fatalf("Fail to include log: %v", err) log.Fatalf("Fail to include log: %v", err)
} }
// FIXME: SSH key file. // FIXME: SSH key file.

2
cmd/web.go

@ -165,7 +165,7 @@ func newMacaron() *macaron.Macaron {
})) }))
m.Use(toolbox.Toolboxer(m, toolbox.Options{ m.Use(toolbox.Toolboxer(m, toolbox.Options{
HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
&toolbox.HealthCheckFuncDesc{ {
Desc: "Database connection", Desc: "Database connection",
Func: models.Ping, Func: models.Ping,
}, },

100
models/git_diff_test.go

@ -1,70 +1,70 @@
package models package models
import ( import (
dmp "github.com/sergi/go-diff/diffmatchpatch" dmp "github.com/sergi/go-diff/diffmatchpatch"
"html/template" "html/template"
"testing" "testing"
) )
func assertEqual(t *testing.T, s1 string, s2 template.HTML) { func assertEqual(t *testing.T, s1 string, s2 template.HTML) {
if s1 != string(s2) { if s1 != string(s2) {
t.Errorf("%s should be equal %s", s2, s1) t.Errorf("%s should be equal %s", s2, s1)
} }
} }
func assertLineEqual(t *testing.T, d1 *DiffLine, d2 *DiffLine) { func assertLineEqual(t *testing.T, d1 *DiffLine, d2 *DiffLine) {
if d1 != d2 { if d1 != d2 {
t.Errorf("%v should be equal %v", d1, d2) t.Errorf("%v should be equal %v", d1, d2)
} }
} }
func TestDiffToHTML(t *testing.T) { func TestDiffToHTML(t *testing.T) {
assertEqual(t, "foo <span class=\"added-code\">bar</span> biz", diffToHTML([]dmp.Diff{ assertEqual(t, "foo <span class=\"added-code\">bar</span> biz", diffToHTML([]dmp.Diff{
dmp.Diff{dmp.DiffEqual, "foo "}, {dmp.DiffEqual, "foo "},
dmp.Diff{dmp.DiffInsert, "bar"}, {dmp.DiffInsert, "bar"},
dmp.Diff{dmp.DiffDelete, " baz"}, {dmp.DiffDelete, " baz"},
dmp.Diff{dmp.DiffEqual, " biz"}, {dmp.DiffEqual, " biz"},
}, DIFF_LINE_ADD)) }, DIFF_LINE_ADD))
assertEqual(t, "foo <span class=\"removed-code\">bar</span> biz", diffToHTML([]dmp.Diff{ assertEqual(t, "foo <span class=\"removed-code\">bar</span> biz", diffToHTML([]dmp.Diff{
dmp.Diff{dmp.DiffEqual, "foo "}, {dmp.DiffEqual, "foo "},
dmp.Diff{dmp.DiffDelete, "bar"}, {dmp.DiffDelete, "bar"},
dmp.Diff{dmp.DiffInsert, " baz"}, {dmp.DiffInsert, " baz"},
dmp.Diff{dmp.DiffEqual, " biz"}, {dmp.DiffEqual, " biz"},
}, DIFF_LINE_DEL)) }, DIFF_LINE_DEL))
} }
// test if GetLine is return the correct lines // test if GetLine is return the correct lines
func TestGetLine(t *testing.T) { func TestGetLine(t *testing.T) {
ds := DiffSection{Lines: []*DiffLine{ ds := DiffSection{Lines: []*DiffLine{
&DiffLine{LeftIdx: 28, RightIdx: 28, Type: DIFF_LINE_PLAIN}, {LeftIdx: 28, RightIdx: 28, Type: DIFF_LINE_PLAIN},
&DiffLine{LeftIdx: 29, RightIdx: 29, Type: DIFF_LINE_PLAIN}, {LeftIdx: 29, RightIdx: 29, Type: DIFF_LINE_PLAIN},
&DiffLine{LeftIdx: 30, RightIdx: 30, Type: DIFF_LINE_PLAIN}, {LeftIdx: 30, RightIdx: 30, Type: DIFF_LINE_PLAIN},
&DiffLine{LeftIdx: 31, RightIdx: 0, Type: DIFF_LINE_DEL}, {LeftIdx: 31, RightIdx: 0, Type: DIFF_LINE_DEL},
&DiffLine{LeftIdx: 0, RightIdx: 31, Type: DIFF_LINE_ADD}, {LeftIdx: 0, RightIdx: 31, Type: DIFF_LINE_ADD},
&DiffLine{LeftIdx: 0, RightIdx: 32, Type: DIFF_LINE_ADD}, {LeftIdx: 0, RightIdx: 32, Type: DIFF_LINE_ADD},
&DiffLine{LeftIdx: 32, RightIdx: 33, Type: DIFF_LINE_PLAIN}, {LeftIdx: 32, RightIdx: 33, Type: DIFF_LINE_PLAIN},
&DiffLine{LeftIdx: 33, RightIdx: 0, Type: DIFF_LINE_DEL}, {LeftIdx: 33, RightIdx: 0, Type: DIFF_LINE_DEL},
&DiffLine{LeftIdx: 34, RightIdx: 0, Type: DIFF_LINE_DEL}, {LeftIdx: 34, RightIdx: 0, Type: DIFF_LINE_DEL},
&DiffLine{LeftIdx: 35, RightIdx: 0, Type: DIFF_LINE_DEL}, {LeftIdx: 35, RightIdx: 0, Type: DIFF_LINE_DEL},
&DiffLine{LeftIdx: 36, RightIdx: 0, Type: DIFF_LINE_DEL}, {LeftIdx: 36, RightIdx: 0, Type: DIFF_LINE_DEL},
&DiffLine{LeftIdx: 0, RightIdx: 34, Type: DIFF_LINE_ADD}, {LeftIdx: 0, RightIdx: 34, Type: DIFF_LINE_ADD},
&DiffLine{LeftIdx: 0, RightIdx: 35, Type: DIFF_LINE_ADD}, {LeftIdx: 0, RightIdx: 35, Type: DIFF_LINE_ADD},
&DiffLine{LeftIdx: 0, RightIdx: 36, Type: DIFF_LINE_ADD}, {LeftIdx: 0, RightIdx: 36, Type: DIFF_LINE_ADD},
&DiffLine{LeftIdx: 0, RightIdx: 37, Type: DIFF_LINE_ADD}, {LeftIdx: 0, RightIdx: 37, Type: DIFF_LINE_ADD},
&DiffLine{LeftIdx: 37, RightIdx: 38, Type: DIFF_LINE_PLAIN}, {LeftIdx: 37, RightIdx: 38, Type: DIFF_LINE_PLAIN},
&DiffLine{LeftIdx: 38, RightIdx: 39, Type: DIFF_LINE_PLAIN}, {LeftIdx: 38, RightIdx: 39, Type: DIFF_LINE_PLAIN},
}} }}
assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 31), ds.Lines[4]) assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 31), ds.Lines[4])
assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 31), ds.Lines[3]) assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 31), ds.Lines[3])
assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 33), ds.Lines[11]) assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 33), ds.Lines[11])
assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 34), ds.Lines[12]) assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 34), ds.Lines[12])
assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 35), ds.Lines[13]) assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 35), ds.Lines[13])
assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 36), ds.Lines[14]) assertLineEqual(t, ds.GetLine(DIFF_LINE_ADD, 36), ds.Lines[14])
assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 34), ds.Lines[7]) assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 34), ds.Lines[7])
assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 35), ds.Lines[8]) assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 35), ds.Lines[8])
assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 36), ds.Lines[9]) assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 36), ds.Lines[9])
assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 37), ds.Lines[10]) assertLineEqual(t, ds.GetLine(DIFF_LINE_DEL, 37), ds.Lines[10])
} }

2
models/wiki.go

@ -7,12 +7,12 @@ package models
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/url"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
"sync" "sync"
"net/url"
"github.com/Unknwon/com" "github.com/Unknwon/com"

1603
modules/bindata/bindata.go

File diff suppressed because it is too large Load Diff

2
modules/user/user.go

@ -5,7 +5,7 @@
package user package user
import ( import (
"os" "os"
) )
func CurrentUsername() string { func CurrentUsername() string {

4
routers/admin/orgs.go

@ -29,14 +29,14 @@ func Organizations(ctx *middleware.Context) {
} }
ctx.Data["Page"] = paginater.New(int(total), setting.AdminOrgPagingNum, page, 5) ctx.Data["Page"] = paginater.New(int(total), setting.AdminOrgPagingNum, page, 5)
orgs, err := models.Organizations(page, setting.AdminOrgPagingNum) orgs, err := models.Organizations(page, setting.AdminOrgPagingNum)
if err != nil { if err != nil {
ctx.Handle(500, "Organizations", err) ctx.Handle(500, "Organizations", err)
return return
} }
ctx.Data["Orgs"] = orgs ctx.Data["Orgs"] = orgs
ctx.Data["Total"] = total ctx.Data["Total"] = total
ctx.HTML(200, ORGS) ctx.HTML(200, ORGS)

2
routers/repo/view.go

@ -199,7 +199,7 @@ func Home(ctx *middleware.Context) {
if len(treename) > 0 { if len(treename) > 0 {
treenames = strings.Split(treename, "/") treenames = strings.Split(treename, "/")
for i, _ := range treenames { for i := range treenames {
Paths = append(Paths, strings.Join(treenames[0:i+1], "/")) Paths = append(Paths, strings.Join(treenames[0:i+1], "/"))
} }

Loading…
Cancel
Save