diff --git a/payload.go b/payload.go index 74c39aa..15d722f 100644 --- a/payload.go +++ b/payload.go @@ -26,7 +26,7 @@ type Payload interface { // MessageHead returns the head of the commit message (i.e. the first line). // The PayloadCommon of the outer PayloadUnion is passed in for added // context, if necessary. - MessageHead(PayloadCommon) (string, error) + MessageHead(PayloadCommon) string // Fingerprint returns the raw fingerprint which can be signed when // accrediting this payload. The ChangedFile objects given describe the file @@ -126,11 +126,7 @@ func (p PayloadUnion) Type() string { // MarshalText implements the encoding.TextMarshaler interface by returning the // form the payload in the git commit message. func (p PayloadUnion) MarshalText() ([]byte, error) { - msgHead, err := p.Payload().MessageHead(p.Common) - if err != nil { - return nil, fmt.Errorf("constructing message head: %w", err) - } - + msgHead := abbrevCommitMessage(p.Payload().MessageHead(p.Common)) msgBodyB, err := yaml.Marshal(p) if err != nil { return nil, fmt.Errorf("marshaling payload %+v as yaml: %w", p, err) diff --git a/payload_change.go b/payload_change.go index 034ce31..c252e3d 100644 --- a/payload_change.go +++ b/payload_change.go @@ -58,8 +58,8 @@ func (proj *Project) NewPayloadChange(description string) (PayloadUnion, error) } // MessageHead implements the method for the Payload interface. -func (payCh PayloadChange) MessageHead(PayloadCommon) (string, error) { - return abbrevCommitMessage(payCh.Description), nil +func (payCh PayloadChange) MessageHead(PayloadCommon) string { + return payCh.Description } // Fingerprint implements the method for the Payload interface. diff --git a/payload_comment.go b/payload_comment.go index a4c1eb4..83970d8 100644 --- a/payload_comment.go +++ b/payload_comment.go @@ -2,8 +2,6 @@ package dehub import ( "errors" - "fmt" - "strings" ) // PayloadComment describes the structure of a comment payload. @@ -28,10 +26,8 @@ func (proj *Project) NewPayloadComment(comment string) (PayloadUnion, error) { } // MessageHead implements the method for the Payload interface. -func (payCom PayloadComment) MessageHead(common PayloadCommon) (string, error) { - credIDs := strings.Join(common.credIDs(), ", ") - fullMsgHead := fmt.Sprintf("Comment by %s: %s", credIDs, payCom.Comment) - return abbrevCommitMessage(fullMsgHead), nil +func (payCom PayloadComment) MessageHead(common PayloadCommon) string { + return `"` + payCom.Comment + `"` } // Fingerprint implements the method for the Payload interface. diff --git a/payload_credential.go b/payload_credential.go index 1800944..9b114d0 100644 --- a/payload_credential.go +++ b/payload_credential.go @@ -2,8 +2,6 @@ package dehub import ( "errors" - "fmt" - "strings" ) // PayloadCredential describes the structure of a credential payload. @@ -52,14 +50,8 @@ func (proj *Project) NewPayloadCredentialFromChanges(commits []Commit) (PayloadU } // MessageHead implements the method for the Payload interface. -func (payCred PayloadCredential) MessageHead(common PayloadCommon) (string, error) { - fingerprintStr := common.Fingerprint.String() - if len(fingerprintStr) > 9 { - fingerprintStr = fingerprintStr[:6] + "..." - } - credIDs := strings.Join(common.credIDs(), ", ") - fullMsgHead := fmt.Sprintf("Credential of hash %s by %s", fingerprintStr, credIDs) - return abbrevCommitMessage(fullMsgHead), nil +func (payCred PayloadCredential) MessageHead(common PayloadCommon) string { + return "Credential of " + common.Fingerprint.String() } // Fingerprint implements the method for the Payload interface.