Browse Source

#2907 Add commit timestamp to webhook

for-closed-social
Unknwon 8 years ago
parent
commit
c5d4a9e046
5 changed files with 21 additions and 17 deletions
  1. +1
    -1
      .gopmfile
  2. +1
    -1
      cmd/web.go
  3. +1
    -1
      glide.lock
  4. +12
    -10
      models/action.go
  5. +6
    -4
      models/update.go

+ 1
- 1
.gopmfile View File

@ -19,7 +19,7 @@ github.com/go-xorm/xorm = commit:b8b1711
github.com/gogits/chardet = commit:2404f77 github.com/gogits/chardet = commit:2404f77
github.com/gogits/cron = commit:96040e4 github.com/gogits/cron = commit:96040e4
github.com/gogits/git-module = commit:18dd87d github.com/gogits/git-module = commit:18dd87d
github.com/gogits/go-gogs-client = commit:d725743
github.com/gogits/go-gogs-client = commit:d1020b4
github.com/issue9/identicon = commit:d36b545 github.com/issue9/identicon = commit:d36b545
github.com/jaytaylor/html2text = commit:52d9b78 github.com/jaytaylor/html2text = commit:52d9b78
github.com/kardianos/minwinsvc = commit:cad6b2b github.com/kardianos/minwinsvc = commit:cad6b2b

+ 1
- 1
cmd/web.go View File

@ -88,7 +88,7 @@ func checkVersion() {
{"gopkg.in/ini.v1", ini.Version, "1.8.4"}, {"gopkg.in/ini.v1", ini.Version, "1.8.4"},
{"gopkg.in/macaron.v1", macaron.Version, "1.1.7"}, {"gopkg.in/macaron.v1", macaron.Version, "1.1.7"},
{"github.com/gogits/git-module", git.Version, "0.3.4"}, {"github.com/gogits/git-module", git.Version, "0.3.4"},
{"github.com/gogits/go-gogs-client", gogs.Version, "0.10.1"},
{"github.com/gogits/go-gogs-client", gogs.Version, "0.10.3"},
} }
for _, c := range checkers { for _, c := range checkers {
if !version.Compare(c.Version(), c.Expected, ">=") { if !version.Compare(c.Version(), c.Expected, ">=") {

+ 1
- 1
glide.lock View File

@ -43,7 +43,7 @@ imports:
- name: github.com/gogits/git-module - name: github.com/gogits/git-module
version: 18dd87dc5eac9ee7076133c8363803f2192d5713 version: 18dd87dc5eac9ee7076133c8363803f2192d5713
- name: github.com/gogits/go-gogs-client - name: github.com/gogits/go-gogs-client
version: d725743594dfcd8eea25024f8456c9c103dadb1a
version: d1020b4da5474f7533f5b11084dcfd5536cf2e71
- name: github.com/issue9/identicon - name: github.com/issue9/identicon
version: d36b54562f4cf70c83653e13dc95c220c79ef521 version: d36b54562f4cf70c83653e13dc95c220c79ef521
- name: github.com/jaytaylor/html2text - name: github.com/jaytaylor/html2text

+ 12
- 10
models/action.go View File

@ -238,6 +238,7 @@ type PushCommit struct {
Message string Message string
AuthorEmail string AuthorEmail string
AuthorName string AuthorName string
Timestamp time.Time
} }
type PushCommits struct { type PushCommits struct {
@ -256,21 +257,22 @@ func NewPushCommits() *PushCommits {
func (pc *PushCommits) ToApiPayloadCommits(repoLink string) []*api.PayloadCommit { func (pc *PushCommits) ToApiPayloadCommits(repoLink string) []*api.PayloadCommit {
commits := make([]*api.PayloadCommit, len(pc.Commits)) commits := make([]*api.PayloadCommit, len(pc.Commits))
for i, cmt := range pc.Commits {
author_username := ""
author, err := GetUserByEmail(cmt.AuthorEmail)
for i, commit := range pc.Commits {
authorUsername := ""
author, err := GetUserByEmail(commit.AuthorEmail)
if err == nil { if err == nil {
author_username = author.Name
authorUsername = author.Name
} }
commits[i] = &api.PayloadCommit{ commits[i] = &api.PayloadCommit{
ID: cmt.Sha1,
Message: cmt.Message,
URL: fmt.Sprintf("%s/commit/%s", repoLink, cmt.Sha1),
ID: commit.Sha1,
Message: commit.Message,
URL: fmt.Sprintf("%s/commit/%s", repoLink, commit.Sha1),
Author: &api.PayloadAuthor{ Author: &api.PayloadAuthor{
Name: cmt.AuthorName,
Email: cmt.AuthorEmail,
UserName: author_username,
Name: commit.AuthorName,
Email: commit.AuthorEmail,
UserName: authorUsername,
}, },
Timestamp: commit.Timestamp,
} }
} }
return commits return commits

+ 6
- 4
models/update.go View File

@ -56,10 +56,12 @@ func ListToPushCommits(l *list.List) *PushCommits {
actEmail = commit.Committer.Email actEmail = commit.Committer.Email
} }
commits = append(commits, commits = append(commits,
&PushCommit{commit.ID.String(),
commit.Message(),
commit.Author.Email,
commit.Author.Name,
&PushCommit{
Sha1: commit.ID.String(),
Message: commit.Message(),
AuthorEmail: commit.Author.Email,
AuthorName: commit.Author.Name,
Timestamp: commit.Author.When,
}) })
} }
return &PushCommits{l.Len(), commits, "", nil} return &PushCommits{l.Len(), commits, "", nil}

Loading…
Cancel
Save