From e085d7738a683785a5d7d7e3a33a0437c87c340b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 29 Mar 2014 14:35:27 +0800 Subject: [PATCH 1/5] add mysql create db sql file --- conf/mysql.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 conf/mysql.sql diff --git a/conf/mysql.sql b/conf/mysql.sql new file mode 100644 index 0000000000..6247d657bb --- /dev/null +++ b/conf/mysql.sql @@ -0,0 +1,2 @@ +DROP DATABASE gogs; +CREATE DATABASE IF NOT EXISTS gogs CHARACTER SET utf8 COLLATE utf8_general_ci; \ No newline at end of file From beb1761d7c9c2bd85a9f67895836c77ec4bbb6bc Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 29 Mar 2014 06:55:51 -0400 Subject: [PATCH 2/5] Mirror fix --- gogs.go | 2 +- routers/repo/issue.go | 1 + templates/user/dashboard.tmpl | 2 +- templates/user/profile.tmpl | 3 +-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gogs.go b/gogs.go index f4b7c72feb..f1372f0cfc 100644 --- a/gogs.go +++ b/gogs.go @@ -19,7 +19,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.9.0328 Alpha" +const APP_VER = "0.1.9.0329 Alpha" func init() { base.AppVer = APP_VER diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 6ac8a53579..14876e1863 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -221,6 +221,7 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat } func Comment(ctx *middleware.Context, params martini.Params) { + fmt.Println(ctx.Query("change_status")) if !ctx.Repo.IsValid { ctx.Handle(404, "issue.Comment(invalid repo):", nil) } diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl index bc0853fb0d..6064095b11 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -18,7 +18,7 @@ {{range .Feeds}}
  • -
    {{TimeSince .Created}}
    {{ActionDesc . | str2html}}
    +
    {{TimeSince .Created}}
    {{ActionDesc . $.SignedUser.AvatarLink | str2html}}
  • {{else}} diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 3733736dde..5ac8121f8b 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -32,11 +32,10 @@ {{if eq .TabName "activity"}}
      - {{$avatarLink := .Owner.AvatarLink}} {{range .Feeds}}
    • -
      {{TimeSince .Created}}
      {{ActionDesc . $avatarLink | str2html}}
      +
      {{TimeSince .Created}}
      {{ActionDesc . $.Owner.AvatarLink | str2html}}
    • {{else}} From a726c125b572bc1ff0b445990821280e304db9ff Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 29 Mar 2014 19:29:52 +0800 Subject: [PATCH 3/5] Add PushCommit --- modules/base/tool.go | 11 +++++++++-- routers/repo/repo.go | 8 +++----- update.go | 8 ++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/base/tool.go b/modules/base/tool.go index 9ddb90f721..d005ffe355 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -506,9 +506,16 @@ const (
      user-avatar %s
      ` ) +type PushCommit struct { + Sha1 string + Message string + AuthorEmail string + AuthorName string +} + type PushCommits struct { Len int - Commits [][]string + Commits []*PushCommit } // ActionDesc accepts int that represents action operation type @@ -529,7 +536,7 @@ func ActionDesc(act Actioner, avatarLink string) string { } buf := bytes.NewBuffer([]byte("\n")) for _, commit := range push.Commits { - buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, repoLink, commit[0], commit[0][:7], commit[1]) + "\n") + buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n") } if push.Len > 3 { buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len)) diff --git a/routers/repo/repo.go b/routers/repo/repo.go index e7107ad1cd..b9ac1f1c42 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -276,11 +276,9 @@ func Http(ctx *middleware.Context, params martini.Params) { } prefix := path.Join("/", username, params["reponame"]) - server := &webdav.Server{ - Fs: webdav.Dir(models.RepoPath(username, reponame)), - TrimPrefix: prefix, - Listings: true, - } + server := webdav.NewServer( + models.RepoPath(username, reponame), + prefix, true) server.ServeHTTP(ctx.ResponseWriter, ctx.Req) } diff --git a/update.go b/update.go index faec0029ac..9743dcc480 100644 --- a/update.go +++ b/update.go @@ -130,11 +130,15 @@ func runUpdate(c *cli.Context) { return } - commits := make([][]string, 0) + commits := make([]*base.PushCommit, 0) var maxCommits = 3 for e := l.Front(); e != nil; e = e.Next() { commit := e.Value.(*git.Commit) - commits = append(commits, []string{commit.Id().String(), commit.Message()}) + commits = append(commits, + &base.PushCommit{commit.Id().String(), + commit.Message(), + commit.Author.Email, + commit.Author.Name}) if len(commits) >= maxCommits { break } From 828282882066aa4e8bd8fb0c083c530607bc34bb Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 29 Mar 2014 07:50:25 -0400 Subject: [PATCH 4/5] Fix action email bug --- models/action.go | 13 +++++++++---- modules/base/tool.go | 8 +++++--- routers/repo/issue.go | 2 +- routers/user/user.go | 2 +- templates/user/dashboard.tmpl | 2 +- templates/user/profile.tmpl | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/models/action.go b/models/action.go index 9d99df8546..894855784f 100644 --- a/models/action.go +++ b/models/action.go @@ -31,6 +31,7 @@ type Action struct { OpType int // Operations: CREATE DELETE STAR ... ActUserId int64 // Action user id. ActUserName string // Action user name. + ActEmail string RepoId int64 RepoName string RefName string @@ -46,6 +47,10 @@ func (a Action) GetActUserName() string { return a.ActUserName } +func (a Action) GetActEmail() string { + return a.ActEmail +} + func (a Action) GetRepoName() string { return a.RepoName } @@ -69,8 +74,8 @@ func CommitRepoAction(userId int64, userName string, return err } - if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, OpType: OP_COMMIT_REPO, - Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil { + if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: "", + OpType: OP_COMMIT_REPO, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil { log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName) return err } @@ -93,8 +98,8 @@ func CommitRepoAction(userId int64, userName string, // NewRepoAction adds new action for creating repository. func NewRepoAction(user *User, repo *Repository) (err error) { - if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, OpType: OP_CREATE_REPO, - RepoId: repo.Id, RepoName: repo.Name}); err != nil { + if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email, + OpType: OP_CREATE_REPO, RepoId: repo.Id, RepoName: repo.Name}); err != nil { log.Error("action.NewRepoAction(notify watchers): %d/%s", user.Id, repo.Name) return err } diff --git a/modules/base/tool.go b/modules/base/tool.go index d005ffe355..6876da7625 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -478,6 +478,7 @@ func (a argInt) Get(i int, args ...int) (r int) { type Actioner interface { GetOpType() int GetActUserName() string + GetActEmail() string GetRepoName() string GetBranch() string GetContent() string @@ -520,8 +521,9 @@ type PushCommits struct { // ActionDesc accepts int that represents action operation type // and returns the description. -func ActionDesc(act Actioner, avatarLink string) string { +func ActionDesc(act Actioner) string { actUserName := act.GetActUserName() + email := act.GetActEmail() repoName := act.GetRepoName() repoLink := actUserName + "/" + repoName branch := act.GetBranch() @@ -536,7 +538,7 @@ func ActionDesc(act Actioner, avatarLink string) string { } buf := bytes.NewBuffer([]byte("\n")) for _, commit := range push.Commits { - buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n") + buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n") } if push.Len > 3 { buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len)) @@ -546,7 +548,7 @@ func ActionDesc(act Actioner, avatarLink string) string { case 6: // Create issue. infos := strings.SplitN(content, "|", 2) return fmt.Sprintf(TPL_CREATE_Issue, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], - avatarLink, infos[1]) + AvatarLink(email), infos[1]) default: return "invalid type" } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 14876e1863..c89c8b5685 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -105,7 +105,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat } // Notify watchers. - if err = models.NotifyWatchers(&models.Action{ActUserId: ctx.User.Id, ActUserName: ctx.User.Name, + if err = models.NotifyWatchers(&models.Action{ActUserId: ctx.User.Id, ActUserName: ctx.User.Name, ActEmail: ctx.User.Email, OpType: models.OP_CREATE_ISSUE, Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name), RepoId: ctx.Repo.Repository.Id, RepoName: ctx.Repo.Repository.Name, RefName: ""}); err != nil { ctx.Handle(200, "issue.CreateIssue", err) diff --git a/routers/user/user.go b/routers/user/user.go index b0fc583978..114169e606 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -279,7 +279,7 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) { feeds := make([]string, len(actions)) for i := range actions { feeds[i] = fmt.Sprintf(TPL_FEED, base.ActionIcon(actions[i].OpType), - base.TimeSince(actions[i].Created), base.ActionDesc(actions[i], ctx.User.AvatarLink())) + base.TimeSince(actions[i].Created), base.ActionDesc(actions[i])) } ctx.JSON(200, &feeds) } diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl index 6064095b11..bc0853fb0d 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -18,7 +18,7 @@ {{range .Feeds}}
    • -
      {{TimeSince .Created}}
      {{ActionDesc . $.SignedUser.AvatarLink | str2html}}
      +
      {{TimeSince .Created}}
      {{ActionDesc . | str2html}}
    • {{else}} diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 5ac8121f8b..97549d481c 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -35,7 +35,7 @@ {{range .Feeds}}
    • -
      {{TimeSince .Created}}
      {{ActionDesc . $.Owner.AvatarLink | str2html}}
      +
      {{TimeSince .Created}}
      {{ActionDesc . | str2html}}
    • {{else}} From ec1b801732b030648c060d26ce5a3ed8cf2e822c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 29 Mar 2014 19:59:02 +0800 Subject: [PATCH 5/5] bug fixed --- models/action.go | 4 ++-- update.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/models/action.go b/models/action.go index 894855784f..1e55df85e9 100644 --- a/models/action.go +++ b/models/action.go @@ -64,7 +64,7 @@ func (a Action) GetContent() string { } // CommitRepoAction adds new action for committing repository. -func CommitRepoAction(userId int64, userName string, +func CommitRepoAction(userId int64, userName, actEmail string, repoId int64, repoName string, refName string, commit *base.PushCommits) error { log.Trace("action.CommitRepoAction(start): %d/%s", userId, repoName) @@ -74,7 +74,7 @@ func CommitRepoAction(userId int64, userName string, return err } - if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: "", + if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: actEmail, OpType: OP_COMMIT_REPO, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil { log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName) return err diff --git a/update.go b/update.go index 9743dcc480..246c5d8f9d 100644 --- a/update.go +++ b/update.go @@ -132,8 +132,12 @@ func runUpdate(c *cli.Context) { commits := make([]*base.PushCommit, 0) var maxCommits = 3 + var actEmail string for e := l.Front(); e != nil; e = e.Next() { commit := e.Value.(*git.Commit) + if actEmail == "" { + actEmail = commit.Committer.Email + } commits = append(commits, &base.PushCommit{commit.Id().String(), commit.Message(), @@ -145,7 +149,7 @@ func runUpdate(c *cli.Context) { } //commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()}) - if err = models.CommitRepoAction(int64(sUserId), userName, + if err = models.CommitRepoAction(int64(sUserId), userName, actEmail, repos.Id, repoName, git.BranchName(refName), &base.PushCommits{l.Len(), commits}); err != nil { log.Error("runUpdate.models.CommitRepoAction: %v", err) }