From 3a4d69bae0283ee6c3c768fa9b95042191f924b8 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Mon, 4 Nov 2019 08:15:54 -0500 Subject: [PATCH] git: move icons to each commit/event --- plugins/git/gitea.go | 5 +++-- plugins/git/github.go | 10 ++++++---- plugins/git/gitlab.go | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/git/gitea.go b/plugins/git/gitea.go index 7b08a0b..5674e55 100644 --- a/plugins/git/gitea.go +++ b/plugins/git/gitea.go @@ -24,10 +24,11 @@ func (p *GitPlugin) giteaEvent(w http.ResponseWriter, r *http.Request) { org := evt.Repository.Owner.Username repo := evt.Repository.Name - msg := icon + " " + msg := " " for _, c := range evt.Commits { 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, repo, c.URL, diff --git a/plugins/git/github.go b/plugins/git/github.go index c6664b2..2893130 100644 --- a/plugins/git/github.go +++ b/plugins/git/github.go @@ -29,7 +29,7 @@ func (p *GitPlugin) githubEvent(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "unknown event: %+v", err) return } - msg, repo, owner := icon+" ", "", "" + msg, repo, owner := " ", "", "" switch payload.(type) { case 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 { 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, repo, c.URL, @@ -60,7 +61,8 @@ func (p *GitPlugin) githubEvent(w http.ResponseWriter, r *http.Request) { } repo = pr.Repository.Name 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.Title, pr.Repository.Name, @@ -70,7 +72,7 @@ func (p *GitPlugin) githubEvent(w http.ResponseWriter, r *http.Request) { ping := payload.(github.PingPayload) repo = ping.Repository.Name 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: log.Error().Interface("payload", payload).Msg("unknown event payload") w.WriteHeader(500) diff --git a/plugins/git/gitlab.go b/plugins/git/gitlab.go index 4469f3c..bb43745 100644 --- a/plugins/git/gitlab.go +++ b/plugins/git/gitlab.go @@ -27,7 +27,7 @@ func (p *GitPlugin) gitlabEvent(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "unknown event: %s", err) return } - msg, repo, owner := icon+" ", "", "" + msg, repo, owner := " ", "", "" switch payload.(type) { case gitlab.PushEventPayload: push := payload.(gitlab.PushEventPayload) @@ -36,7 +36,8 @@ func (p *GitPlugin) gitlabEvent(w http.ResponseWriter, r *http.Request) { commits := "" for _, c := range push.Commits { 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, repo, c.URL,