Add PushCommit
This commit is contained in:
parent
f48fc24670
commit
a726c125b5
3 changed files with 18 additions and 9 deletions
|
@ -506,9 +506,16 @@ const (
|
||||||
<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
|
<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type PushCommit struct {
|
||||||
|
Sha1 string
|
||||||
|
Message string
|
||||||
|
AuthorEmail string
|
||||||
|
AuthorName string
|
||||||
|
}
|
||||||
|
|
||||||
type PushCommits struct {
|
type PushCommits struct {
|
||||||
Len int
|
Len int
|
||||||
Commits [][]string
|
Commits []*PushCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionDesc accepts int that represents action operation type
|
// ActionDesc accepts int that represents action operation type
|
||||||
|
@ -529,7 +536,7 @@ func ActionDesc(act Actioner, avatarLink string) string {
|
||||||
}
|
}
|
||||||
buf := bytes.NewBuffer([]byte("\n"))
|
buf := bytes.NewBuffer([]byte("\n"))
|
||||||
for _, commit := range push.Commits {
|
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 {
|
if push.Len > 3 {
|
||||||
buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
|
buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
|
||||||
|
|
|
@ -276,11 +276,9 @@ func Http(ctx *middleware.Context, params martini.Params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix := path.Join("/", username, params["reponame"])
|
prefix := path.Join("/", username, params["reponame"])
|
||||||
server := &webdav.Server{
|
server := webdav.NewServer(
|
||||||
Fs: webdav.Dir(models.RepoPath(username, reponame)),
|
models.RepoPath(username, reponame),
|
||||||
TrimPrefix: prefix,
|
prefix, true)
|
||||||
Listings: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
server.ServeHTTP(ctx.ResponseWriter, ctx.Req)
|
server.ServeHTTP(ctx.ResponseWriter, ctx.Req)
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,11 +130,15 @@ func runUpdate(c *cli.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
commits := make([][]string, 0)
|
commits := make([]*base.PushCommit, 0)
|
||||||
var maxCommits = 3
|
var maxCommits = 3
|
||||||
for e := l.Front(); e != nil; e = e.Next() {
|
for e := l.Front(); e != nil; e = e.Next() {
|
||||||
commit := e.Value.(*git.Commit)
|
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 {
|
if len(commits) >= maxCommits {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue