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. 10
      routers/admin/orgs.go
  8. 2
      routers/repo/view.go
  9. 2
      routers/user/profile.go

10
cmd/dump.go

@ -68,21 +68,21 @@ func runDump(ctx *cli.Context) {
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)
}
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)
}
customDir, err := os.Stat(setting.CustomPath)
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)
}
}
} else {
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)
}
// FIXME: SSH key file.

2
cmd/web.go

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

100
models/git_diff_test.go

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

2
models/wiki.go

@ -7,12 +7,12 @@ package models
import (
"fmt"
"io/ioutil"
"net/url"
"os"
"path"
"path/filepath"
"strings"
"sync"
"net/url"
"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
import (
"os"
"os"
)
func CurrentUsername() string {

10
routers/admin/orgs.go

@ -28,15 +28,15 @@ func Organizations(ctx *middleware.Context) {
page = 1
}
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 {
ctx.Handle(500, "Organizations", err)
return
}
ctx.Data["Orgs"] = orgs
ctx.Data["Orgs"] = orgs
ctx.Data["Total"] = total
ctx.HTML(200, ORGS)

2
routers/repo/view.go

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

2
routers/user/profile.go

@ -74,7 +74,7 @@ func Profile(ctx *middleware.Context) {
ctx.Data["Title"] = u.DisplayName()
ctx.Data["PageIsUserProfile"] = true
ctx.Data["Owner"] = u
orgs, err := models.GetOwnedOrgsByUserIDDesc(u.Id, "updated")
if err != nil {
ctx.Handle(500, "GetOwnedOrgsByUserIDDesc", err)

Loading…
Cancel
Save