git: move icons to each commit/event

This commit is contained in:
Chris Sexton 2019-11-04 08:15:54 -05:00 committed by Chris Sexton
parent 7f5f62d04a
commit 3a4d69bae0
3 changed files with 12 additions and 8 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,