diff --git a/plugins/git/gitea.go b/plugins/git/gitea.go index 5674e55..47166d7 100644 --- a/plugins/git/gitea.go +++ b/plugins/git/gitea.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "net/http" + "sort" "strings" "github.com/rs/zerolog/log" @@ -25,7 +26,11 @@ func (p *GitPlugin) giteaEvent(w http.ResponseWriter, r *http.Request) { repo := evt.Repository.Name msg := " " - for _, c := range evt.Commits { + commits := evt.Commits + sort.Slice(commits, func(i, j int) bool { + return commits[i].Timestamp.Before(commits[j].Timestamp) + }) + for _, c := range commits { m := strings.Split(c.Message, "\n")[0] msg += fmt.Sprintf("%s %s pushed to %s (<%s|%s>) %s\n", icon, diff --git a/plugins/git/gitea_push.go b/plugins/git/gitea_push.go index a102478..ddd5ab0 100644 --- a/plugins/git/gitea_push.go +++ b/plugins/git/gitea_push.go @@ -1,5 +1,7 @@ package git +import "time" + type GiteaPush struct { Secret string `json:"secret"` Ref string `json:"ref"` @@ -20,7 +22,7 @@ type GiteaPush struct { Email string `json:"email"` Username string `json:"username"` } `json:"committer"` - Timestamp string `json:"timestamp"` + Timestamp time.Time `json:"timestamp"` } `json:"commits"` Repository struct { ID int `json:"id"`