From c5d4a9e046045f949ec9606b49dc37b928e83fb3 Mon Sep 17 00:00:00 2001
From: Unknwon <u@gogs.io>
Date: Tue, 9 Aug 2016 18:28:06 -0700
Subject: [PATCH] #2907 Add commit timestamp to webhook

---
 .gopmfile        |  2 +-
 cmd/web.go       |  2 +-
 glide.lock       |  2 +-
 models/action.go | 22 ++++++++++++----------
 models/update.go | 10 ++++++----
 5 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/.gopmfile b/.gopmfile
index 1aa540b3be..8d09ed9638 100644
--- a/.gopmfile
+++ b/.gopmfile
@@ -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
diff --git a/cmd/web.go b/cmd/web.go
index ea3a34d961..f2f7279bf0 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -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, ">=") {
diff --git a/glide.lock b/glide.lock
index 0e135ae1ae..18d1ddd66b 100644
--- a/glide.lock
+++ b/glide.lock
@@ -43,7 +43,7 @@ imports:
 - name: github.com/gogits/git-module
   version: 18dd87dc5eac9ee7076133c8363803f2192d5713
 - name: github.com/gogits/go-gogs-client
-  version: d725743594dfcd8eea25024f8456c9c103dadb1a
+  version: d1020b4da5474f7533f5b11084dcfd5536cf2e71
 - name: github.com/issue9/identicon
   version: d36b54562f4cf70c83653e13dc95c220c79ef521
 - name: github.com/jaytaylor/html2text
diff --git a/models/action.go b/models/action.go
index 081f96bb2a..4f57d1b3b5 100644
--- a/models/action.go
+++ b/models/action.go
@@ -238,6 +238,7 @@ type PushCommit struct {
 	Message     string
 	AuthorEmail string
 	AuthorName  string
+	Timestamp   time.Time
 }
 
 type PushCommits struct {
@@ -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
diff --git a/models/update.go b/models/update.go
index 14e5b28cf2..9b2078c986 100644
--- a/models/update.go
+++ b/models/update.go
@@ -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}