Skip to content
Snippets Groups Projects
Commit 3792d24b authored by Tulir Asokan's avatar Tulir Asokan :cat2:
Browse files

Fix long commit message detector

parent 408e02df
No related branches found
No related tags found
No related merge requests found
...@@ -101,9 +101,10 @@ func handlePushEvent(payload interface{}, header webhooks.Header) { ...@@ -101,9 +101,10 @@ func handlePushEvent(payload interface{}, header webhooks.Header) {
fmt.Fprintln(&msg, "<ul>") fmt.Fprintln(&msg, "<ul>")
for i := len(data.Commits) - 1; i >= 0; i-- { for i := len(data.Commits) - 1; i >= 0; i-- {
commit := data.Commits[i] commit := data.Commits[i]
message := commit.Message lines := strings.Split(commit.Message, "\n")
if strings.Contains(message, "\n") { message := lines[0]
message = fmt.Sprintf("%s (...)", strings.Split(message, "\n")[0]) if len(lines) > 1 && len(strings.Join(lines[1:], "")) > 0 {
message += " (...)"
} }
fmt.Fprintf(&msg, "<li>%s (%s)</li>\n", message, commit.ID[:8]) fmt.Fprintf(&msg, "<li>%s (%s)</li>\n", message, commit.ID[:8])
} }
...@@ -112,9 +113,10 @@ func handlePushEvent(payload interface{}, header webhooks.Header) { ...@@ -112,9 +113,10 @@ func handlePushEvent(payload interface{}, header webhooks.Header) {
} else { } else {
for i := len(data.Commits) - 1; i >= 0; i-- { for i := len(data.Commits) - 1; i >= 0; i-- {
commit := data.Commits[i] commit := data.Commits[i]
message := commit.Message lines := strings.Split(commit.Message, "\n")
if strings.Contains(message, "\n") { message := lines[0]
message = fmt.Sprintf("%s (...)", strings.Split(message, "\n")[0]) if len(lines) > 1 && len(strings.Join(lines[1:], "")) > 0 {
message += " (...)"
} }
room.SendfHTML("<ul><li>%s (%s)</li></ul>", message, commit.ID[:8]) room.SendfHTML("<ul><li>%s (%s)</li></ul>", message, commit.ID[:8])
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment