mirror of https://github.com/velour/catbase.git
git: order gitea commits
This commit is contained in:
parent
6e66498d25
commit
72da1d3c78
|
@ -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,
|
||||
|
|
|
@ -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"`
|
||||
|
|
Loading…
Reference in New Issue