mirror of https://github.com/velour/catbase.git
git: move icons to each commit/event
This commit is contained in:
parent
7f5f62d04a
commit
3a4d69bae0
|
@ -24,10 +24,11 @@ func (p *GitPlugin) giteaEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
org := evt.Repository.Owner.Username
|
org := evt.Repository.Owner.Username
|
||||||
repo := evt.Repository.Name
|
repo := evt.Repository.Name
|
||||||
|
|
||||||
msg := icon + " "
|
msg := " "
|
||||||
for _, c := range evt.Commits {
|
for _, c := range evt.Commits {
|
||||||
m := strings.Split(c.Message, "\n")[0]
|
m := strings.Split(c.Message, "\n")[0]
|
||||||
msg += fmt.Sprintf("%s pushed to %s (<%s|%s>) %s\n",
|
msg += fmt.Sprintf("%s %s pushed to %s (<%s|%s>) %s\n",
|
||||||
|
icon,
|
||||||
c.Author.Name,
|
c.Author.Name,
|
||||||
repo,
|
repo,
|
||||||
c.URL,
|
c.URL,
|
||||||
|
|
|
@ -29,7 +29,7 @@ func (p *GitPlugin) githubEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "unknown event: %+v", err)
|
fmt.Fprintf(w, "unknown event: %+v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg, repo, owner := icon+" ", "", ""
|
msg, repo, owner := " ", "", ""
|
||||||
switch payload.(type) {
|
switch payload.(type) {
|
||||||
case github.PushPayload:
|
case github.PushPayload:
|
||||||
push := payload.(github.PushPayload)
|
push := payload.(github.PushPayload)
|
||||||
|
@ -42,7 +42,8 @@ func (p *GitPlugin) githubEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
for _, c := range push.Commits {
|
for _, c := range push.Commits {
|
||||||
m := strings.Split(c.Message, "\n")[0]
|
m := strings.Split(c.Message, "\n")[0]
|
||||||
commits += fmt.Sprintf("%s pushed to %s (<%s|%s>) %s\n",
|
commits += fmt.Sprintf("%s %s pushed to %s (<%s|%s>) %s\n",
|
||||||
|
icon,
|
||||||
c.Author.Name,
|
c.Author.Name,
|
||||||
repo,
|
repo,
|
||||||
c.URL,
|
c.URL,
|
||||||
|
@ -60,7 +61,8 @@ func (p *GitPlugin) githubEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
repo = pr.Repository.Name
|
repo = pr.Repository.Name
|
||||||
owner = pr.Repository.Owner.Login
|
owner = pr.Repository.Owner.Login
|
||||||
msg += fmt.Sprintf("%s opened new pull request \"%s\" on %s: %s",
|
msg += fmt.Sprintf("%s %s opened new pull request \"%s\" on %s: %s",
|
||||||
|
icon,
|
||||||
pr.PullRequest.User.Login,
|
pr.PullRequest.User.Login,
|
||||||
pr.PullRequest.Title,
|
pr.PullRequest.Title,
|
||||||
pr.Repository.Name,
|
pr.Repository.Name,
|
||||||
|
@ -70,7 +72,7 @@ func (p *GitPlugin) githubEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
ping := payload.(github.PingPayload)
|
ping := payload.(github.PingPayload)
|
||||||
repo = ping.Repository.Name
|
repo = ping.Repository.Name
|
||||||
owner = ping.Repository.Owner.Login
|
owner = ping.Repository.Owner.Login
|
||||||
msg += fmt.Sprintf(icon+"Got a ping request on %s", repo)
|
msg += fmt.Sprintf(icon+" Got a ping request on %s", repo)
|
||||||
default:
|
default:
|
||||||
log.Error().Interface("payload", payload).Msg("unknown event payload")
|
log.Error().Interface("payload", payload).Msg("unknown event payload")
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
|
|
|
@ -27,7 +27,7 @@ func (p *GitPlugin) gitlabEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "unknown event: %s", err)
|
fmt.Fprintf(w, "unknown event: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg, repo, owner := icon+" ", "", ""
|
msg, repo, owner := " ", "", ""
|
||||||
switch payload.(type) {
|
switch payload.(type) {
|
||||||
case gitlab.PushEventPayload:
|
case gitlab.PushEventPayload:
|
||||||
push := payload.(gitlab.PushEventPayload)
|
push := payload.(gitlab.PushEventPayload)
|
||||||
|
@ -36,7 +36,8 @@ func (p *GitPlugin) gitlabEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
commits := ""
|
commits := ""
|
||||||
for _, c := range push.Commits {
|
for _, c := range push.Commits {
|
||||||
m := strings.Split(c.Message, "\n")[0]
|
m := strings.Split(c.Message, "\n")[0]
|
||||||
commits += fmt.Sprintf("%s pushed to %s (<%s|%s>) %s\n",
|
commits += fmt.Sprintf("%s %s pushed to %s (<%s|%s>) %s\n",
|
||||||
|
icon,
|
||||||
c.Author.Name,
|
c.Author.Name,
|
||||||
repo,
|
repo,
|
||||||
c.URL,
|
c.URL,
|
||||||
|
|
Loading…
Reference in New Issue