Browse Source

Actually shorten the commit SHA

kegan/text-logging
Kegan Dougal 8 years ago
parent
commit
07574c1f0d
  1. 6
      src/github.com/matrix-org/go-neb/services/travisci/travisci.go
  2. 6
      src/github.com/matrix-org/go-neb/services/travisci/travisci_test.go

6
src/github.com/matrix-org/go-neb/services/travisci/travisci.go

@ -118,7 +118,11 @@ func notifToTemplate(n webhookNotification) map[string]string {
t["build_number"] = n.Number t["build_number"] = n.Number
t["build_id"] = strconv.Itoa(n.ID) t["build_id"] = strconv.Itoa(n.ID)
t["branch"] = n.Branch t["branch"] = n.Branch
t["commit"] = n.Commit
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 t["author"] = n.CommitterName // author: commit author name
// commit_message: commit message of build // commit_message: commit message of build
// commit_subject: first line of the commit message // commit_subject: first line of the commit message

6
src/github.com/matrix-org/go-neb/services/travisci/travisci_test.go

@ -71,18 +71,18 @@ var travisTests = []struct {
{ {
exampleSignature, true, exampleBody, exampleSignature, true, exampleBody,
"%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}", "%{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, "obviously_invalid_signature", false, exampleBody,
"%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}", "%{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 // Payload is valid but doesn't match signature now
exampleSignature, false, strings.TrimSuffix(exampleBody, "%7D") + "%2C%22EXTRA_KEY%22%3Anull%7D", exampleSignature, false, strings.TrimSuffix(exampleBody, "%7D") + "%2C%22EXTRA_KEY%22%3Anull%7D",
"%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}", "%{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, exampleSignature, true, exampleBody,

Loading…
Cancel
Save