Pārlūkot izejas kodu

Merge pull request #37 from achilleas-k/rebase/codestyle

LGTM
Michael Sonntag 6 gadi atpakaļ
vecāks
revīzija
6a425b6a34

+ 1 - 1
models/git_diff.go

@@ -17,9 +17,9 @@ import (
 
 	"github.com/G-Node/git-module"
 
-	"github.com/G-Node/gogs/pkg/tool"
 	"github.com/G-Node/gogs/pkg/setting"
 	"github.com/G-Node/gogs/pkg/template/highlight"
+	"github.com/G-Node/gogs/pkg/tool"
 )
 
 type DiffSection struct {

+ 8 - 6
pkg/dav/dav.go

@@ -9,8 +9,10 @@ import (
 	"strings"
 	"time"
 
+	"io/ioutil"
+
 	"github.com/G-Node/git-module"
-	"github.com/G-Node/go-annex"
+	gannex "github.com/G-Node/go-annex"
 	"github.com/G-Node/gogs/models"
 	gctx "github.com/G-Node/gogs/pkg/context"
 	"github.com/G-Node/gogs/pkg/setting"
@@ -18,7 +20,6 @@ import (
 	"golang.org/x/net/context"
 	"golang.org/x/net/webdav"
 	log "gopkg.in/clog.v1"
-	"io/ioutil"
 )
 
 var (
@@ -47,21 +48,22 @@ type GinFS struct {
 	BasePath string
 }
 
-// Just return an error. -> Read Only
+// Mkdir not implemented: Just return an error. -> Read Only
 func (fs *GinFS) Mkdir(ctx context.Context, name string, perm os.FileMode) error {
 	return fmt.Errorf("Mkdir not implemented for read only gin FS")
 }
 
-// Just return an error. -> Read Only
+// RemoveAll not implemented: Just return an error. -> Read Only
 func (fs *GinFS) RemoveAll(ctx context.Context, name string) error {
 	return fmt.Errorf("RemoveAll not implemented for read only gin FS")
 }
 
-// Just return an error. -> Read Only
+// Rename not implemented: Just return an error. -> Read Only
 func (fs *GinFS) Rename(ctx context.Context, oldName, newName string) error {
 	return fmt.Errorf("Rename not implemented for read only gin FS")
 }
 
+// OpenFile returns a named file from the repository
 func (fs *GinFS) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error) {
 	//todo: catch all the errors
 	rname, err := getRName(name)
@@ -225,7 +227,7 @@ func (f *GinFile) Readdir(count int) ([]os.FileInfo, error) {
 		f.dirrcount = len(ents)
 		return infos, io.EOF
 	case f.dirrcount+count < len(ents):
-		infos, err := f.getFInfos(ents[f.dirrcount: f.dirrcount+count])
+		infos, err := f.getFInfos(ents[f.dirrcount : f.dirrcount+count])
 		if err != nil {
 			return nil, err
 		}

+ 5 - 3
pkg/dav/middle.go

@@ -1,14 +1,16 @@
 package dav
 
 import (
-	"gopkg.in/macaron.v1"
-	"strings"
 	"net/http"
+	"strings"
+
+	"github.com/G-Node/git-module"
 	"github.com/G-Node/gogs/models"
 	"github.com/G-Node/gogs/pkg/context"
-	"github.com/G-Node/git-module"
+	"gopkg.in/macaron.v1"
 )
 
+// DavMiddle initialises and returns a WebDav middleware handler (macaron.Handler)
 // [0]: issues, [1]: wiki
 func DavMiddle() macaron.Handler {
 	return func(c *context.Context) {

+ 1 - 1
pkg/form/repo.go

@@ -88,7 +88,7 @@ type RepoSetting struct {
 	Interval      int
 	MirrorAddress string
 	Private       bool
-	Listed      bool
+	Listed        bool
 	EnablePrune   bool
 
 	// Advanced settings

+ 1 - 1
pkg/mailer/mailer.go

@@ -52,7 +52,7 @@ func NewMessageFrom(to []string, from, subject, htmlBody string) *Message {
 	}
 	msg.SetBody(contentType, body)
 	if switchedToPlaintext && setting.MailService.AddPlainTextAlt && !setting.MailService.UsePlainText {
-		// The AddAlternative method name is confusing - adding html as an "alternative" will actually cause mail 
+		// The AddAlternative method name is confusing - adding html as an "alternative" will actually cause mail
 		// clients to show it as first priority, and the text "main body" is the 2nd priority fallback.
 		// See: https://godoc.org/gopkg.in/gomail.v2#Message.AddAlternative
 		msg.AddAlternative("text/html", htmlBody)

+ 2 - 3
pkg/markup/markup.go

@@ -28,17 +28,16 @@ func IsIPythonNotebook(name string) bool {
 	return strings.HasSuffix(name, ".ipynb")
 }
 
-// Is JSON return whethe a filename looks liek it could be  ajson file
+// IsJSON returns whether a filename looks like a JSON file based on its extension.
 func IsJSON(name string) bool {
 	return strings.HasSuffix(name, ".json")
 }
 
-// Is YAML return whethe a filename looks like it could be  a yaml file
+// IsYAML returns whether a filename looks like a YAML file based on its extension.
 func IsYAML(name string) bool {
 	return strings.HasSuffix(name, ".yml")
 }
 
-
 const (
 	ISSUE_NAME_STYLE_NUMERIC      = "numeric"
 	ISSUE_NAME_STYLE_ALPHANUMERIC = "alphanumeric"

+ 2 - 2
routes/api/v1/api.go

@@ -167,7 +167,7 @@ func RegisterRoutes(m *macaron.Macaron) {
 		m.Post("/markdown", bind(api.MarkdownOption{}), misc.Markdown)
 		m.Post("/markdown/raw", misc.MarkdownRaw)
 
-		m.Get("/search/:querry", search.Search)
+		m.Get("/search/:query", search.Search)
 
 		// Users
 		m.Group("/users", func() {
@@ -228,7 +228,7 @@ func RegisterRoutes(m *macaron.Macaron) {
 			m.Get("/search", repo.Search)
 
 			m.Get("/:username/:reponame", repoAssignment(), repo.Get)
-			m.Get("/suggest/:querry", search.Suggest)
+			m.Get("/suggest/:query", search.Suggest)
 		})
 
 		m.Group("/repos", func() {

+ 6 - 4
routes/api/v1/misc/client.go

@@ -1,12 +1,13 @@
 package misc
 
 import (
-	"github.com/G-Node/gogs/pkg/context"
-	"github.com/G-Node/gogs/pkg/setting"
 	"encoding/json"
+	"fmt"
 	"net/http"
+
+	"github.com/G-Node/gogs/pkg/context"
+	"github.com/G-Node/gogs/pkg/setting"
 	log "gopkg.in/clog.v1"
-	"fmt"
 )
 
 type CliCongig struct {
@@ -20,9 +21,10 @@ type ApiCliConfig struct {
 	SSHUser string
 	SSHPort int
 }
+
 func ClientC(c *context.APIContext) {
 	cf := ApiCliConfig{RSAKet: setting.CliConfig.RsaHostKey,
-		Weburl: fmt.Sprintf("%s://%s", setting.Protocol, setting.Domain),
+		Weburl:  fmt.Sprintf("%s://%s", setting.Protocol, setting.Domain),
 		Webport: setting.HTTPPort, SSHUrl: setting.SSH.Domain, SSHPort: setting.SSH.Port,
 		SSHUser: setting.RunUser}
 	data, err := json.Marshal(cf)

+ 1 - 1
routes/api/v1/repo/repo.go

@@ -28,7 +28,7 @@ func Search(c *context.APIContext) {
 		Page:     c.QueryInt("page"),
 	}
 
-	// workaround for the all querry with logged users
+	// workaround for the all query with logged users
 	if opts.Keyword == "." {
 		opts.Keyword = ""
 	}

+ 1 - 1
routes/api/v1/search/general.go

@@ -21,7 +21,7 @@ func Search(c *context.APIContext) {
 		return
 	}
 	ireq := libgin.SearchRequest{Token: c.GetCookie(setting.SessionConfig.CookieName), UserID: c.User.ID,
-		Querry: c.Params("querry"), CsrfT: c.GetCookie(setting.CSRFCookieName)}
+		Query: c.Params("query"), CsrfT: c.GetCookie(setting.CSRFCookieName)}
 	data, err := json.Marshal(ireq)
 	if err != nil {
 		c.Status(http.StatusInternalServerError)

+ 1 - 1
routes/api/v1/search/suggest.go

@@ -17,7 +17,7 @@ func Suggest(c *context.APIContext) {
 		return
 	}
 	ireq := libgin.SearchRequest{Token: c.GetCookie(setting.SessionConfig.CookieName),
-		Querry: c.Params("querry"), CsrfT: c.GetCookie(setting.CSRFCookieName), SType: libgin.SEARCH_SUGGEST}
+		Query: c.Params("query"), CsrfT: c.GetCookie(setting.CSRFCookieName), SType: libgin.SEARCH_SUGGEST}
 	if c.IsLogged {
 		ireq.UserID = c.User.ID
 	}

+ 4 - 3
routes/repo/download.go

@@ -9,13 +9,14 @@ import (
 	"path"
 
 	"github.com/G-Node/git-module"
+	gannex "github.com/G-Node/go-annex"
 
 	"bufio"
-	"github.com/G-Node/go-annex"
+	"os"
+
 	"github.com/G-Node/gogs/pkg/context"
 	"github.com/G-Node/gogs/pkg/setting"
 	"github.com/G-Node/gogs/pkg/tool"
-	"os"
 	"github.com/go-macaron/captcha"
 )
 
@@ -33,7 +34,7 @@ func ServeData(c *context.Context, name string, reader io.Reader, cpt *captcha.C
 		if err != nil {
 
 		}
-		if cpt!=nil && af.Info.Size() > gannex.MEGABYTE*setting.Repository.RawCaptchaMinFileSize && !cpt.VerifyReq(c.Req) &&
+		if cpt != nil && af.Info.Size() > gannex.MEGABYTE*setting.Repository.RawCaptchaMinFileSize && !cpt.VerifyReq(c.Req) &&
 			!c.IsLogged {
 			c.Data["EnableCaptcha"] = true
 			c.HTML(200, "repo/download")

+ 3 - 3
routes/repo/editor.go

@@ -526,8 +526,8 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
 func UploadFileToServer(c *context.Context) {
 	file, header, err := c.Req.FormFile("file")
 	fvalue := c.Req.Form
-	f_dir := filepath.Dir(fvalue.Get("full_path"))
-	log.Info("full_path:%s", f_dir)
+	fp := filepath.Dir(fvalue.Get("full_path"))
+	log.Info("full_path:%s", fp)
 	if err != nil {
 		c.Error(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
 		return
@@ -557,7 +557,7 @@ func UploadFileToServer(c *context.Context) {
 		}
 	}
 
-	upload, err := models.NewUpload(filepath.Join(f_dir, header.Filename), buf, file)
+	upload, err := models.NewUpload(filepath.Join(fp, header.Filename), buf, file)
 	if err != nil {
 		c.Error(http.StatusInternalServerError, fmt.Sprintf("NewUpload: %v", err))
 		return

+ 4 - 3
routes/repo/view.go

@@ -510,11 +510,12 @@ func Forks(c *context.Context) {
 	c.HTML(200, FORKS)
 }
 
-// Get the (theoretical ) doi for a repository. Make sure its tge doi for the Base repo
-// in cas eits a repo from the doi user
+// GDoiRepo calculates the theoretical DOI for a repository. If the repository
+// belongs to the DOI user (and is a fork) it uses the name for the base
+// repository.
 func GDoiRepo(c *context.Context, doiBase string) string {
 	repoN := c.Repo.Repository.FullName()
-	// check whether this repo belongs to doi and is a fork
+	// check whether this repo belongs to DOI and is a fork
 	if c.Repo.Repository.IsFork && c.Repo.Owner.Name == "doi" {
 		repoN = c.Repo.Repository.BaseRepo.FullName()
 	}

+ 3 - 3
routes/search.go

@@ -26,7 +26,7 @@ func Search(c *context.Context, keywords string, sType int64) ([]byte, error) {
 	}
 
 	ireq := libgin.SearchRequest{Token: c.GetCookie(setting.SessionConfig.CookieName),
-		Querry: keywords, CsrfT: c.GetCookie(setting.CSRFCookieName), SType: sType, UserID: -10}
+		Query: keywords, CsrfT: c.GetCookie(setting.CSRFCookieName), SType: sType, UserID: -10}
 	if c.IsLogged {
 		ireq.UserID = c.User.ID
 	}
@@ -65,7 +65,7 @@ func ExploreData(c *context.Context) {
 	}
 	data, err := Search(c, keywords, sType)
 	if err != nil {
-		c.Handle(http.StatusInternalServerError, "Could not querry", err)
+		c.Handle(http.StatusInternalServerError, "Could not query", err)
 		return
 	}
 
@@ -112,6 +112,6 @@ type SearchRequest struct {
 	Token  string
 	CsrfT  string
 	UserID int64
-	Querry string
+	Query  string
 	SType  int64
 }

+ 2 - 2
vendor/github.com/G-Node/libgin/libgin/dex.go

@@ -12,7 +12,7 @@ type SearchRequest struct {
 	Token  string
 	CsrfT  string
 	UserID int64
-	Querry string
+	Query  string
 	SType  int64
 }
 
@@ -20,7 +20,7 @@ const (
 	SEARCH_MATCH = iota
 	SEARCH_FUZZY
 	SEARCH_WILDCARD
-	SEARCH_QUERRY
+	SEARCH_QUERY
 	SEARCH_SUGGEST
 )