From 07574c1f0d716f7efb5c3eea4f5c0e8a6a62a445 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 17 Nov 2016 17:23:36 +0000 Subject: [PATCH] Actually shorten the commit SHA --- .../matrix-org/go-neb/services/travisci/travisci.go | 8 ++++++-- .../matrix-org/go-neb/services/travisci/travisci_test.go | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/github.com/matrix-org/go-neb/services/travisci/travisci.go b/src/github.com/matrix-org/go-neb/services/travisci/travisci.go index 716bcbd..89ad304 100644 --- a/src/github.com/matrix-org/go-neb/services/travisci/travisci.go +++ b/src/github.com/matrix-org/go-neb/services/travisci/travisci.go @@ -118,8 +118,12 @@ func notifToTemplate(n webhookNotification) map[string]string { t["build_number"] = n.Number t["build_id"] = strconv.Itoa(n.ID) t["branch"] = n.Branch - t["commit"] = n.Commit - t["author"] = n.CommitterName // author: commit author name + shaLength := len(n.Commit) + if shaLength > 10 { + shaLength = 10 + } + t["commit"] = n.Commit[:shaLength] // shortened commit SHA + t["author"] = n.CommitterName // author: commit author name // commit_message: commit message of build // commit_subject: first line of the commit message t["commit_message"] = n.Message diff --git a/src/github.com/matrix-org/go-neb/services/travisci/travisci_test.go b/src/github.com/matrix-org/go-neb/services/travisci/travisci_test.go index f2527c3..5a8e2e5 100644 --- a/src/github.com/matrix-org/go-neb/services/travisci/travisci_test.go +++ b/src/github.com/matrix-org/go-neb/services/travisci/travisci_test.go @@ -71,18 +71,18 @@ var travisTests = []struct { { exampleSignature, true, exampleBody, "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}", - "Kegsay/flow-jsdoc#18 (master - 3a092c3a6032ebb50384c99b445f947e9ce86e2a : Kegan Dougal): Passed", + "Kegsay/flow-jsdoc#18 (master - 3a092c3a60 : Kegan Dougal): Passed", }, { "obviously_invalid_signature", false, exampleBody, "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}", - "Kegsay/flow-jsdoc#18 (master - 3a092c3a6032ebb50384c99b445f947e9ce86e2a : Kegan Dougal): Passed", + "Kegsay/flow-jsdoc#18 (master - 3a092c3a60 : Kegan Dougal): Passed", }, { // Payload is valid but doesn't match signature now exampleSignature, false, strings.TrimSuffix(exampleBody, "%7D") + "%2C%22EXTRA_KEY%22%3Anull%7D", "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}", - "Kegsay/flow-jsdoc#18 (master - 3a092c3a6032ebb50384c99b445f947e9ce86e2a : Kegan Dougal): Passed", + "Kegsay/flow-jsdoc#18 (master - 3a092c3a60 : Kegan Dougal): Passed", }, { exampleSignature, true, exampleBody,