From a726c125b572bc1ff0b445990821280e304db9ff Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 29 Mar 2014 19:29:52 +0800 Subject: [PATCH] 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 9ddb90f72..d005ffe35 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(`
%d other commits >>
`, actUserName, repoName, branch, push.Len)) diff --git a/routers/repo/repo.go b/routers/repo/repo.go index e7107ad1c..b9ac1f1c4 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 faec0029a..9743dcc48 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 }