Skip to content

Commit

Permalink
gogs#2907 Add commit timestamp to webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon committed Aug 10, 2016
1 parent edd7864 commit c5d4a9e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gopmfile
Expand Up @@ -19,7 +19,7 @@ github.com/go-xorm/xorm = commit:b8b1711
github.com/gogits/chardet = commit:2404f77
github.com/gogits/cron = commit:96040e4
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/jaytaylor/html2text = commit:52d9b78
github.com/kardianos/minwinsvc = commit:cad6b2b
Expand Down
2 changes: 1 addition & 1 deletion cmd/web.go
Expand Up @@ -88,7 +88,7 @@ func checkVersion() {
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
{"gopkg.in/macaron.v1", macaron.Version, "1.1.7"},
{"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 {
if !version.Compare(c.Version(), c.Expected, ">=") {
Expand Down
2 changes: 1 addition & 1 deletion glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions models/action.go
Expand Up @@ -238,6 +238,7 @@ type PushCommit struct {
Message string
AuthorEmail string
AuthorName string
Timestamp time.Time
}

type PushCommits struct {
Expand All @@ -256,21 +257,22 @@ func NewPushCommits() *PushCommits {

func (pc *PushCommits) ToApiPayloadCommits(repoLink string) []*api.PayloadCommit {
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 {
author_username = author.Name
authorUsername = author.Name
}
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{
Name: cmt.AuthorName,
Email: cmt.AuthorEmail,
UserName: author_username,
Name: commit.AuthorName,
Email: commit.AuthorEmail,
UserName: authorUsername,
},
Timestamp: commit.Timestamp,
}
}
return commits
Expand Down
10 changes: 6 additions & 4 deletions models/update.go
Expand Up @@ -56,10 +56,12 @@ func ListToPushCommits(l *list.List) *PushCommits {
actEmail = commit.Committer.Email
}
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}
Expand Down

0 comments on commit c5d4a9e

Please sign in to comment.