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"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
@ -25,7 +26,11 @@ func (p *GitPlugin) giteaEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
repo := evt.Repository.Name
|
repo := evt.Repository.Name
|
||||||
|
|
||||||
msg := " "
|
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]
|
m := strings.Split(c.Message, "\n")[0]
|
||||||
msg += fmt.Sprintf("%s %s pushed to %s (<%s|%s>) %s\n",
|
msg += fmt.Sprintf("%s %s pushed to %s (<%s|%s>) %s\n",
|
||||||
icon,
|
icon,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package git
|
package git
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type GiteaPush struct {
|
type GiteaPush struct {
|
||||||
Secret string `json:"secret"`
|
Secret string `json:"secret"`
|
||||||
Ref string `json:"ref"`
|
Ref string `json:"ref"`
|
||||||
|
@ -20,7 +22,7 @@ type GiteaPush struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
} `json:"committer"`
|
} `json:"committer"`
|
||||||
Timestamp string `json:"timestamp"`
|
Timestamp time.Time `json:"timestamp"`
|
||||||
} `json:"commits"`
|
} `json:"commits"`
|
||||||
Repository struct {
|
Repository struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
|
|
Loading…
Reference in New Issue