From f8cfb81fb027313e45b8ce505200f3d48b306fe2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 23 Mar 2014 12:16:17 -0400 Subject: [PATCH 1/7] Mirror updates --- CONTRIBUTING.md | 40 +++++++++------------------------ models/user.go | 5 ++++- modules/log/log.go | 4 ++++ routers/repo/issue.go | 4 ++++ routers/repo/repo.go | 12 ++++++++-- templates/repo/nav.tmpl | 4 ++-- templates/repo/toolbar.tmpl | 12 +++++----- templates/user/dashboard.tmpl | 4 ++-- templates/user/issues.tmpl | 4 ++-- templates/user/setting_nav.tmpl | 4 ++-- 10 files changed, 46 insertions(+), 47 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 08013d370..1b71d5313 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,49 +1,29 @@ # Contributing to Gogs -Want to hack on Gogs? Awesome! Here are instructions to get you -started. They are probably not perfect, please let us know if anything -feels wrong or incomplete. +> Thanks [drone](https://github.com/drone/drone) because this guidelines sheet is forked from its [CONTRIBUTING.md](https://github.com/drone/drone/blob/master/CONTRIBUTING.md). + +Want to hack on Gogs? Awesome! Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or incomplete. ## Contribution guidelines ### Pull requests are always welcome -We are always thrilled to receive pull requests, and do our best to -process them as fast as possible. Not sure if that typo is worth a pull -request? Do it! We will appreciate it. +We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it. -If your pull request is not accepted on the first try, don't be -discouraged! If there's a problem with the implementation, hopefully you -received feedback on what to improve. +If your pull request is not accepted on the first try, don't be discouraged! If there's a problem with the implementation, hopefully you received feedback on what to improve. -We're trying very hard to keep Gogs lean and focused. We don't want it -to do everything for everybody. This means that we might decide against -incorporating a new feature. +We're trying very hard to keep Gogs lean and focused. We don't want it to do everything for everybody. This means that we might decide against incorporating a new feature. ### Discuss your design on the mailing list -We recommend discussing your plans [on the mailing -list](https://groups.google.com/forum/#!forum/gogits) -before starting to code - especially for more ambitious contributions. -This gives other contributors a chance to point you in the right -direction, give feedback on your design, and maybe point out if someone -else is working on the same thing. +We recommend discussing your plans [on the mailing list](https://groups.google.com/forum/#!forum/gogits) before starting to code - especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give feedback on your design, and maybe point out if someone else is working on the same thing. -We may close your pull request if not first discussed on the mailing -list. We aren't doing this to be jerks. We are doing this to prevent -people from spending large amounts of time on changes that may need -to be designed or architected in a specific way, or may not align with -the vision of the project. +We may close your pull request if not first discussed on the mailing list. We aren't doing this to be jerks. We are doing this to prevent people from spending large amounts of time on changes that may need to be designed or architected in a specific way, or may not align with the vision of the project. ### Create issues... -Any significant improvement should be documented as [a GitHub -issue](https://github.com/gogits/gogs/issues) before anybody -starts working on it. +Any significant improvement should be documented as [a GitHub issue](https://github.com/gogits/gogs/issues) before anybody starts working on it. ### ...but check for existing issues first! -Please take a moment to check that an issue doesn't already exist -documenting your bug report or improvement proposal. If it does, it -never hurts to add a quick "+1" or "I have this problem too". This will -help prioritize the most common problems and requests. \ No newline at end of file +Please take a moment to check that an issue doesn't already exist documenting your bug report or improvement proposal. If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common problems and requests. \ No newline at end of file diff --git a/models/user.go b/models/user.go index 88bbabe6d..7fd7449ce 100644 --- a/models/user.go +++ b/models/user.go @@ -72,7 +72,10 @@ func (user *User) HomeLink() string { // AvatarLink returns the user gravatar link. func (user *User) AvatarLink() string { - return "/avatar/" + user.Avatar + if base.Service.EnableCacheAvatar { + return "/avatar/" + user.Avatar + } + return "http://1.gravatar.com/avatar/" + user.Avatar } // NewGitSig generates and returns the signature of given user. diff --git a/modules/log/log.go b/modules/log/log.go index 29782fb2b..80ade3d5b 100644 --- a/modules/log/log.go +++ b/modules/log/log.go @@ -20,6 +20,10 @@ func Trace(format string, v ...interface{}) { logger.Trace(format, v...) } +func Debug(format string, v ...interface{}) { + logger.Debug(format, v...) +} + func Info(format string, v ...interface{}) { logger.Info(format, v...) } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 78fe4b25d..a9d879931 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -31,6 +31,10 @@ func Issues(ctx *middleware.Context, params martini.Params) { return } + if len(params["branchname"]) == 0 { + params["branchname"] = "master" + } + ctx.Data["Branchname"] = params["branchname"] ctx.HTML(200, "repo/issues") } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 82956098b..b05ce4a71 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -69,7 +69,10 @@ func Branches(ctx *middleware.Context, params martini.Params) { ctx.Data["Username"] = params["username"] ctx.Data["Reponame"] = params["reponame"] - ctx.Data["Branchname"] = brs[0] + if len(params["branchname"]) == 0 { + params["branchname"] = "master" + } + ctx.Data["Branchname"] = params["branchname"] ctx.Data["Branches"] = brs ctx.Data["IsRepoToolbarBranches"] = true @@ -334,8 +337,13 @@ func Commits(ctx *middleware.Context, params martini.Params) { ctx.HTML(200, "repo/commits") } -func Pulls(ctx *middleware.Context) { +func Pulls(ctx *middleware.Context, params martini.Params) { ctx.Data["IsRepoToolbarPulls"] = true + if len(params["branchname"]) == 0 { + params["branchname"] = "master" + } + + ctx.Data["Branchname"] = params["branchname"] ctx.HTML(200, "repo/pulls") } diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl index a3358fd89..080cb72e5 100644 --- a/templates/repo/nav.tmpl +++ b/templates/repo/nav.tmpl @@ -53,9 +53,9 @@ -
+ {{end}}
 {{.Repository.NumForks}} diff --git a/templates/repo/toolbar.tmpl b/templates/repo/toolbar.tmpl index b51768a3c..415023d17 100644 --- a/templates/repo/toolbar.tmpl +++ b/templates/repo/toolbar.tmpl @@ -6,27 +6,27 @@
  • Source
  • {{if not .IsBareRepo}}
  • Commits
  • -
  • Branches
  • -
  • Pull Requests
  • + +
  • Issues
  • -
    diff --git a/templates/user/issues.tmpl b/templates/user/issues.tmpl index 94f668945..e28af5bec 100644 --- a/templates/user/issues.tmpl +++ b/templates/user/issues.tmpl @@ -5,8 +5,8 @@

    Issues

    diff --git a/templates/user/setting_nav.tmpl b/templates/user/setting_nav.tmpl index 3a500fdaf..2905f2825 100644 --- a/templates/user/setting_nav.tmpl +++ b/templates/user/setting_nav.tmpl @@ -3,9 +3,9 @@ \ No newline at end of file From 003298ef1d53e1d9837bcac5aadb2e9e159a7497 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 23 Mar 2014 12:32:16 -0400 Subject: [PATCH 2/7] Add default behave of logger --- modules/log/log.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/log/log.go b/modules/log/log.go index 80ade3d5b..0c07c7c62 100644 --- a/modules/log/log.go +++ b/modules/log/log.go @@ -11,6 +11,11 @@ import ( var logger *logs.BeeLogger +func init() { + logger = logs.NewLogger(10000) + logger.SetLogger("console", `{"level": 0}`) +} + func NewLogger(bufLen int64, mode, config string) { logger = logs.NewLogger(bufLen) logger.SetLogger(mode, config) From b9b82cfe477bcbfd3541adfc969ff20210d56549 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 23 Mar 2014 19:09:11 -0400 Subject: [PATCH 3/7] Mirror updates --- .gobuild.yml | 3 ++- conf/app.ini | 2 ++ models/issue.go | 19 ++++++++++++++--- modules/base/conf.go | 13 ++++++++++++ routers/repo/issue.go | 40 +++++++++++++++++++++++++++++++++-- templates/admin/config.tmpl | 1 + templates/user/dashboard.tmpl | 2 +- templates/user/profile.tmpl | 2 +- web.go | 3 ++- 9 files changed, 76 insertions(+), 9 deletions(-) diff --git a/.gobuild.yml b/.gobuild.yml index d667c9308..78a38f2d3 100644 --- a/.gobuild.yml +++ b/.gobuild.yml @@ -4,4 +4,5 @@ filesets: - public - conf - LICENSE - - README.md \ No newline at end of file + - README.md + - README_ZH.md \ No newline at end of file diff --git a/conf/app.ini b/conf/app.ini index ee44dd408..809ea61c0 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -52,6 +52,8 @@ DISENABLE_REGISTERATION = false REQUIRE_SIGNIN_VIEW = false ; Cache avatar as picture ENABLE_CACHE_AVATAR = false +; Mail notification +ENABLE_NOTIFY_MAIL = false [mailer] ENABLED = false diff --git a/models/issue.go b/models/issue.go index 929567b1b..fe43a94b5 100644 --- a/models/issue.go +++ b/models/issue.go @@ -58,6 +58,7 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, name, labels, co Content: content, } _, err = orm.Insert(issue) + // TODO: newIssueAction return issue, err } @@ -67,9 +68,9 @@ func GetIssueCount(repoId int64) (int64, error) { } // GetIssueById returns issue object by given id. -func GetIssueById(id int64) (*Issue, error) { - issue := new(Issue) - has, err := orm.Id(id).Get(issue) +func GetIssueByIndex(repoId, index int64) (*Issue, error) { + issue := &Issue{RepoId: repoId, Index: index} + has, err := orm.Get(issue) if err != nil { return nil, err } else if !has { @@ -126,6 +127,18 @@ func GetIssues(userId, repoId, posterId, milestoneId int64, page int, isClosed, return issues, err } +// UpdateIssue updates information of issue. +func UpdateIssue(issue *Issue) error { + _, err := orm.Update(issue, &Issue{RepoId: issue.RepoId, Index: issue.Index}) + return err +} + +func CloseIssue() { +} + +func ReopenIssue() { +} + // Label represents a list of labels of repository for issues. type Label struct { Id int64 diff --git a/modules/base/conf.go b/modules/base/conf.go index b243a6ad5..2bf529d9d 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -66,6 +66,7 @@ var Service struct { DisenableRegisteration bool RequireSignInView bool EnableCacheAvatar bool + NotifyMail bool ActiveCodeLives int ResetPwdCodeLives int } @@ -230,6 +231,17 @@ func newRegisterMailService() { log.Info("Register Mail Service Enabled") } +func newNotifyMailService() { + if !Cfg.MustBool("service", "ENABLE_NOTIFY_MAIL") { + return + } else if MailService == nil { + log.Warn("Notify Mail Service: Mail Service is not enabled") + return + } + Service.NotifyMail = true + log.Info("Notify Mail Service Enabled") +} + func NewConfigContext() { var err error workDir, err := exeDir() @@ -284,4 +296,5 @@ func NewServices() { newSessionService() newMailService() newRegisterMailService() + newNotifyMailService() } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index a9d879931..e03f115e2 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -67,13 +67,13 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat } func ViewIssue(ctx *middleware.Context, params martini.Params) { - issueid, err := base.StrTo(params["issueid"]).Int() + index, err := base.StrTo(params["index"]).Int() if err != nil { ctx.Handle(404, "issue.ViewIssue", err) return } - issue, err := models.GetIssueById(int64(issueid)) + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index)) if err != nil { if err == models.ErrIssueNotExist { ctx.Handle(404, "issue.ViewIssue", err) @@ -87,3 +87,39 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) { ctx.Data["Issue"] = issue ctx.HTML(200, "issue/view") } + +func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) { + if !ctx.Repo.IsOwner { + ctx.Handle(404, "issue.UpdateIssue", nil) + return + } + + index, err := base.StrTo(params["index"]).Int() + if err != nil { + ctx.Handle(404, "issue.UpdateIssue", err) + return + } + + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index)) + if err != nil { + if err == models.ErrIssueNotExist { + ctx.Handle(404, "issue.UpdateIssue", err) + } else { + ctx.Handle(200, "issue.UpdateIssue", err) + } + return + } + + issue.Name = form.IssueName + issue.MilestoneId = form.MilestoneId + issue.AssigneeId = form.AssigneeId + issue.Labels = form.Labels + issue.Content = form.Content + if err = models.UpdateIssue(issue); err != nil { + ctx.Handle(200, "issue.UpdateIssue", err) + return + } + + ctx.Data["Title"] = issue.Name + ctx.Data["Issue"] = issue +} diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index d33a07cc3..1e2630460 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -46,6 +46,7 @@
    Register Email Confirmation:
    Disenable Registeration:
    Require Sign In View:
    +
    Mail Notification:
    Enable Cache Avatar:

    Active Code Lives: {{.Service.ActiveCodeLives}} minutes
    diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl index 6594e5459..ca5fecf26 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -34,7 +34,7 @@
    diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 2d76d9bf0..342236147 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -50,7 +50,7 @@
      {{range .Repos}}
    • -
      {{.NumStars}} {{.NumForks}}
      +
      {{.NumForks}}

      {{.LowerName}}

      diff --git a/web.go b/web.go index 4b7d4ef03..9a613dceb 100644 --- a/web.go +++ b/web.go @@ -145,7 +145,8 @@ func runWeb(*cli.Context) { r.Get("/commits/:branchname", repo.Commits) r.Get("/issues", repo.Issues) r.Any("/issues/new", binding.BindIgnErr(auth.CreateIssueForm{}), repo.CreateIssue) - r.Get("/issues/:issueid", repo.ViewIssue) + r.Get("/issues/:index", repo.ViewIssue) + r.Post("/issues/:index", binding.BindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue) r.Get("/pulls", repo.Pulls) r.Get("/branches", repo.Branches) r.Get("/src/:branchname", repo.Single) From 137538e54b3aade46cf2ef947707f4e32ba8a382 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Mon, 24 Mar 2014 18:25:15 +0800 Subject: [PATCH 4/7] refactor repo.go --- routers/repo/branch.go | 38 +++++++++++++++++++++++++ routers/repo/commit.go | 35 +++++++++++++++++++++++ routers/repo/pull.go | 20 ++++++++++++++ routers/repo/repo.go | 63 +----------------------------------------- 4 files changed, 94 insertions(+), 62 deletions(-) create mode 100644 routers/repo/branch.go create mode 100644 routers/repo/commit.go create mode 100644 routers/repo/pull.go diff --git a/routers/repo/branch.go b/routers/repo/branch.go new file mode 100644 index 000000000..8c953f2ed --- /dev/null +++ b/routers/repo/branch.go @@ -0,0 +1,38 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package repo + +import ( + "github.com/codegangsta/martini" + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/middleware" +) + +func Branches(ctx *middleware.Context, params martini.Params) { + if !ctx.Repo.IsValid { + return + } + + brs, err := models.GetBranches(params["username"], params["reponame"]) + if err != nil { + ctx.Handle(200, "repo.Branches", err) + return + } else if len(brs) == 0 { + ctx.Handle(404, "repo.Branches", nil) + return + } + + ctx.Data["Username"] = params["username"] + ctx.Data["Reponame"] = params["reponame"] + + if len(params["branchname"]) == 0 { + params["branchname"] = "master" + } + ctx.Data["Branchname"] = params["branchname"] + ctx.Data["Branches"] = brs + ctx.Data["IsRepoToolbarBranches"] = true + + ctx.HTML(200, "repo/branches") +} diff --git a/routers/repo/commit.go b/routers/repo/commit.go new file mode 100644 index 000000000..60ee2177f --- /dev/null +++ b/routers/repo/commit.go @@ -0,0 +1,35 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package repo + +import ( + "github.com/codegangsta/martini" + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/middleware" +) + +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.Handle(404, "repo.Commits", nil) + return + } + + ctx.Data["IsRepoToolbarCommits"] = true + commits, err := models.GetCommits(params["username"], + params["reponame"], params["branchname"]) + if err != nil { + ctx.Handle(404, "repo.Commits", nil) + return + } + ctx.Data["Username"] = params["username"] + ctx.Data["Reponame"] = params["reponame"] + ctx.Data["CommitCount"] = commits.Len() + ctx.Data["Commits"] = commits + ctx.HTML(200, "repo/commits") +} diff --git a/routers/repo/pull.go b/routers/repo/pull.go new file mode 100644 index 000000000..d4a12a4a8 --- /dev/null +++ b/routers/repo/pull.go @@ -0,0 +1,20 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package repo + +import ( + "github.com/codegangsta/martini" + "github.com/gogits/gogs/modules/middleware" +) + +func Pulls(ctx *middleware.Context, params martini.Params) { + ctx.Data["IsRepoToolbarPulls"] = true + if len(params["branchname"]) == 0 { + params["branchname"] = "master" + } + + ctx.Data["Branchname"] = params["branchname"] + ctx.HTML(200, "repo/pulls") +} diff --git a/routers/repo/repo.go b/routers/repo/repo.go index b05ce4a71..a055b416c 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -52,33 +52,6 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) { ctx.Handle(200, "repo.Create", err) } -func Branches(ctx *middleware.Context, params martini.Params) { - if !ctx.Repo.IsValid { - return - } - - brs, err := models.GetBranches(params["username"], params["reponame"]) - if err != nil { - ctx.Handle(200, "repo.Branches", err) - return - } else if len(brs) == 0 { - ctx.Handle(404, "repo.Branches", nil) - return - } - - ctx.Data["Username"] = params["username"] - ctx.Data["Reponame"] = params["reponame"] - - if len(params["branchname"]) == 0 { - params["branchname"] = "master" - } - ctx.Data["Branchname"] = params["branchname"] - ctx.Data["Branches"] = brs - ctx.Data["IsRepoToolbarBranches"] = true - - ctx.HTML(200, "repo/branches") -} - func Single(ctx *middleware.Context, params martini.Params) { if !ctx.Repo.IsValid { return @@ -279,7 +252,7 @@ func Setting(ctx *middleware.Context, params martini.Params) { ctx.HTML(200, "repo/setting") } -func SettingPost(ctx *middleware.Context, params martini.Params) { +func SettingPost(ctx *middleware.Context) { if !ctx.Repo.IsOwner { ctx.Error(404) return @@ -313,40 +286,6 @@ func SettingPost(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.Handle(404, "repo.Commits", nil) - return - } - - ctx.Data["IsRepoToolbarCommits"] = true - commits, err := models.GetCommits(params["username"], - params["reponame"], params["branchname"]) - if err != nil { - ctx.Handle(404, "repo.Commits", nil) - return - } - ctx.Data["Username"] = params["username"] - ctx.Data["Reponame"] = params["reponame"] - ctx.Data["CommitCount"] = commits.Len() - ctx.Data["Commits"] = commits - ctx.HTML(200, "repo/commits") -} - -func Pulls(ctx *middleware.Context, params martini.Params) { - ctx.Data["IsRepoToolbarPulls"] = true - if len(params["branchname"]) == 0 { - params["branchname"] = "master" - } - - ctx.Data["Branchname"] = params["branchname"] - ctx.HTML(200, "repo/pulls") -} - func Action(ctx *middleware.Context, params martini.Params) { var err error switch params["action"] { From d44c44987f704e2d4343db8c252281c86adb4a71 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 24 Mar 2014 06:50:11 -0400 Subject: [PATCH 5/7] Fix dashboard auto-log bug --- modules/middleware/auth.go | 2 +- web.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 82c3367c4..64f75d75c 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -21,7 +21,7 @@ type ToggleOptions struct { func Toggle(options *ToggleOptions) martini.Handler { return func(ctx *Context) { - if options.SignOutRequire && ctx.IsSigned { + if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" { ctx.Redirect("/") return } diff --git a/web.go b/web.go index 9a613dceb..4236d8b31 100644 --- a/web.go +++ b/web.go @@ -88,7 +88,7 @@ func runWeb(*cli.Context) { reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true}) // Routers. - m.Get("/", ignSignIn, routers.Home) + m.Get("/", reqSignIn, routers.Home) m.Get("/issues", reqSignIn, user.Issues) m.Get("/pulls", reqSignIn, user.Pulls) m.Get("/stars", reqSignIn, user.Stars) From 59bbddb3183c27cbb5fb7918cefd9bb3a763a410 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 24 Mar 2014 07:36:38 -0400 Subject: [PATCH 6/7] Mirror fix --- CONTRIBUTING.md | 2 ++ README.md | 6 ++++-- README_ZH.md | 10 ++++++---- gogs.go | 2 +- models/repo.go | 2 +- models/user.go | 2 +- routers/repo/pull.go | 1 + web.go | 5 +++-- 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b71d5313..17a3ebe68 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,8 @@ > Thanks [drone](https://github.com/drone/drone) because this guidelines sheet is forked from its [CONTRIBUTING.md](https://github.com/drone/drone/blob/master/CONTRIBUTING.md). +**This document is pre^3 release, we're not ready for receiving contribution until v0.5.0 release.** + Want to hack on Gogs? Awesome! Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or incomplete. ## Contribution guidelines diff --git a/README.md b/README.md index 42eba6362..104b7eab5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0bc450ac6f09bc56b9640a50aa/s/ "wercker status")](https://app.wercker.com/project/bykey/ad0bdb0bc450ac6f09bc56b9640a50aa) [![Build Status](https://drone.io/github.com/gogits/gogs/status.png)](https://drone.io/github.com/gogits/gogs/latest) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gogits/gogs/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0bc450ac6f09bc56b9640a50aa/s/ "wercker status")](https://app.wercker.com/project/bykey/ad0bdb0bc450ac6f09bc56b9640a50aa) [![Build Status](https://drone.io/github.com/gogits/gogs/status.png)](https://drone.io/github.com/gogits/gogs/latest) ===================== Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language. @@ -48,9 +48,11 @@ There are two ways to install Gogs: ## Acknowledgments -- Logo is inspired by [martini](https://github.com/martini-contrib). +- Logo is inspired by [martini-contrib](https://github.com/martini-contrib). +- Router and middleware mechanism of [martini](http://martini.codegangsta.io/). - Mail Service, modules design is inspired by [WeTalk](https://github.com/beego/wetalk). - System Monitor Status is inspired by [GoBlog](https://github.com/fuxiaohei/goblog). +- Usage and modification from [beego](http://beego.me) modules. ## Contributors diff --git a/README_ZH.md b/README_ZH.md index b405e0419..838e30a0e 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,4 +1,4 @@ -Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0bc450ac6f09bc56b9640a50aa/s/ "wercker status")](https://app.wercker.com/project/bykey/ad0bdb0bc450ac6f09bc56b9640a50aa) [![Build Status](https://drone.io/github.com/gogits/gogs/status.png)](https://drone.io/github.com/gogits/gogs/latest) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gogits/gogs/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0bc450ac6f09bc56b9640a50aa/s/ "wercker status")](https://app.wercker.com/project/bykey/ad0bdb0bc450ac6f09bc56b9640a50aa) [![Build Status](https://drone.io/github.com/gogits/gogs/status.png)](https://drone.io/github.com/gogits/gogs/latest) ===================== Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。 @@ -44,9 +44,11 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 ## 特别鸣谢 -- Logo 基于 [martini](https://github.com/martini-contrib) 修改而来。 -- 邮件服务、模块设计基于 [WeTalk](https://github.com/beego/wetalk) 修改而来。 -- 系统监视状态基于 [GoBlog](https://github.com/fuxiaohei/goblog) 修改而来。 +- Logo 基于 [martini-contrib](https://github.com/martini-contrib) 修改而来。 +- 基于 [WeTalk](https://github.com/beego/wetalk) 修改的邮件服务和模块设计。 +- 基于 [GoBlog](https://github.com/fuxiaohei/goblog) 修改的系统监视状态。 +- [beego](http://beego.me) 模块的使用与修改。 +- [martini](http://martini.codegangsta.io/) 的路由与中间件机制。 ## 贡献成员 diff --git a/gogs.go b/gogs.go index 09b28f9b3..93b7231b7 100644 --- a/gogs.go +++ b/gogs.go @@ -20,7 +20,7 @@ import ( // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true -const APP_VER = "0.1.7.0323.1" +const APP_VER = "0.1.7.0324" func init() { base.AppVer = APP_VER diff --git a/models/repo.go b/models/repo.go index e27e99b05..f03d7683d 100644 --- a/models/repo.go +++ b/models/repo.go @@ -387,7 +387,7 @@ func UpdateRepository(repo *Repository) error { repo.Website = repo.Website[:255] } - _, err := orm.Id(repo.Id).UseBool().Cols("description", "website").Update(repo) + _, err := orm.Id(repo.Id).UseBool().Cols("description", "website", "updated").Update(repo) return err } diff --git a/models/user.go b/models/user.go index 7fd7449ce..d2ed5a907 100644 --- a/models/user.go +++ b/models/user.go @@ -211,7 +211,7 @@ func UpdateUser(user *User) (err error) { user.Website = user.Website[:255] } - _, err = orm.Id(user.Id).UseBool().Cols("website", "location", "is_active", "is_admin").Update(user) + _, err = orm.Id(user.Id).UseBool().Cols("email", "passwd", "avatar", "avatar_email", "website", "location", "is_active", "is_admin", "updated").Update(user) return err } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index d4a12a4a8..16c60389d 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -6,6 +6,7 @@ package repo import ( "github.com/codegangsta/martini" + "github.com/gogits/gogs/modules/middleware" ) diff --git a/web.go b/web.go index 4236d8b31..f0f811257 100644 --- a/web.go +++ b/web.go @@ -31,9 +31,10 @@ import ( var CmdWeb = cli.Command{ Name: "web", - Usage: "just run", + Usage: "Gogs web server", Description: ` -gogs web`, +gogs web server is the only thing you need to run, +and it takes care of all the other things for you`, Action: runWeb, Flags: []cli.Flag{}, } From 8376b0d53cae91af0e180c05b9cb92c3f3f30d58 Mon Sep 17 00:00:00 2001 From: shxsun Date: Mon, 24 Mar 2014 21:16:00 +0800 Subject: [PATCH 7/7] use modeles/log instead log --- modules/avatar/avatar.go | 28 +++++++++++++--------------- modules/avatar/avatar_test.go | 13 +++++++++---- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index 1a18d8a7e..0ba20294a 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -3,6 +3,14 @@ // license that can be found in the LICENSE file. // for www.gravatar.com image cache + +/* +It is recommend to use this way + + cacheDir := "./cache" + defaultImg := "./default.jpg" + http.Handle("/avatar/", avatar.HttpHandler(cacheDir, defaultImg)) +*/ package avatar import ( @@ -14,7 +22,6 @@ import ( "image/jpeg" "image/png" "io" - "log" "net/http" "net/url" "os" @@ -23,6 +30,7 @@ import ( "sync" "time" + "github.com/gogits/gogs/modules/log" "github.com/nfnt/resize" ) @@ -30,12 +38,6 @@ var ( gravatar = "http://www.gravatar.com/avatar" ) -func debug(a ...interface{}) { - if true { - log.Println(a...) - } -} - // hash email to md5 string // keep this func in order to make this package indenpent func HashEmail(email string) string { @@ -125,7 +127,7 @@ func (this *Avatar) UpdateTimeout(timeout time.Duration) error { var err error select { case <-time.After(timeout): - err = errors.New("get gravatar image timeout") + err = fmt.Errorf("get gravatar image %s timeout", this.Hash) case err = <-thunder.GoFetch(gravatar+"/"+this.Hash+"?"+this.reqParams, this.imagePath): } @@ -150,16 +152,14 @@ func (this *avatarHandler) mustInt(r *http.Request, defaultValue int, keys ...st func (this *avatarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path hash := urlPath[strings.LastIndex(urlPath, "/")+1:] - //hash = HashEmail(hash) - size := this.mustInt(r, 80, "s", "size") // size = 80*80 + size := this.mustInt(r, 80, "s", "size") // default size = 80*80 avatar := New(hash, this.cacheDir) avatar.AlterImage = this.altImage if avatar.Expired() { err := avatar.UpdateTimeout(time.Millisecond * 500) if err != nil { - debug(err) - //log.Trace("avatar update error: %v", err) + log.Trace("avatar update error: %v", err) } } if modtime, err := avatar.Modtime(); err == nil { @@ -177,8 +177,7 @@ func (this *avatarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "image/jpeg") err := avatar.Encode(w, size) if err != nil { - //log.Warn("avatar encode error: %v", err) // will panic when err != nil - debug(err) + log.Warn("avatar encode error: %v", err) w.WriteHeader(500) } } @@ -251,7 +250,6 @@ func (this *thunderTask) Fetch() { var client = &http.Client{} func (this *thunderTask) fetch() error { - //log.Println("thunder, fetch", this.Url) req, _ := http.NewRequest("GET", this.Url, nil) req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") req.Header.Set("Accept-Encoding", "gzip,deflate,sdch") diff --git a/modules/avatar/avatar_test.go b/modules/avatar/avatar_test.go index a337959c6..4656d6f0f 100644 --- a/modules/avatar/avatar_test.go +++ b/modules/avatar/avatar_test.go @@ -4,13 +4,14 @@ package avatar_test import ( - "log" + "errors" "os" "strconv" "testing" "time" "github.com/gogits/gogs/modules/avatar" + "github.com/gogits/gogs/modules/log" ) const TMPDIR = "test-avatar" @@ -28,7 +29,7 @@ func TestFetchMany(t *testing.T) { os.Mkdir(TMPDIR, 0755) defer os.RemoveAll(TMPDIR) - log.Println("start") + t.Log("start") var n = 5 ch := make(chan bool, n) for i := 0; i < n; i++ { @@ -36,14 +37,14 @@ func TestFetchMany(t *testing.T) { hash := avatar.HashEmail(strconv.Itoa(i) + "ssx205@gmail.com") a := avatar.New(hash, TMPDIR) a.Update() - log.Println("finish", hash) + t.Log("finish", hash) ch <- true }(i) } for i := 0; i < n; i++ { <-ch } - log.Println("end") + t.Log("end") } // cat @@ -54,3 +55,7 @@ func TestHttp(t *testing.T) { http.ListenAndServe(":8001", nil) } */ + +func TestLogTrace(t *testing.T) { + log.Trace("%v", errors.New("console log test")) +}