f085f13fa8
--- type: change description: |- Remove Payload.MessageHead error return and simplify implementations None of the new implementations of Payload.MessageHead can return an error, so don't do it. The new implementations place more reliance on the author field of the commit to describe the "who", so the commit heads have more room to describe the "what". fingerprint: AIf/6pSXd2ao5vKa8Ju0HAKWwPC2xN2RDQtoUfuDZcnc credentials: - type: pgp_signature pub_key_id: 95C46FA6A41148AC body: iQIzBAABAgAdFiEEJ6tQKp6olvZKJ0lwlcRvpqQRSKwFAl66IV0ACgkQlcRvpqQRSKwuVxAAla713T+aeJwqg4PE5VYrcs29Wfmg2Zc/Otk5l9S8zm+csGV4esEHb1gybe1DfvMhSq3V25jMdu/tt0TRHJUiWskzdHAX4xqNv/pMmcMSB18hpyV3YB+kBYtn+9sSBf4y7tYUVIGtRiycAkazTkAHQZmaufxYCfbx/q5irpyQnIdUb+EXy5o4hJnA9ic0bchS6o8vvDNZpAF2ETi6oylt7MAgo4eeB3M+gpT75U7iGOCWn2qA0ofv4h25M9qcMTm+apRUwncueB19v60GpwRFcAMKvlJfsPEwlJpdvGONilZcA+p4tp7jjn5BP1FeE0UtUSDZHq3bVKcVYxm65kV7yABUDvTnhD7/JylsimB4bOabqbkAkIiu15Z1HFomufS7ozTngTI6AFRCvaQiHTmCvsoM8hSUs4NDUEZo8MzSQaAsAsMn3Pn0Vm1YdtOLJ4ELcBPTb02WnpoIRnHoMbUQuCLwHPHPJxU2aMYXs5WSDv6ZlAlGlkZwe63W2NKc80mChObwYH/Wt6lTLX0m/GrBRzl3Tv+DzlpfJ6le+TrF6HdG/D2DmLXl9Cp8hyw0ClNTszaCACy2rAiyqeoMV4acpi3cShdVXDz1dTC51k7V5IkfUtH/QDxJYqc8DJJrUbJqsROF9JUgZCN58RNRaUbjKLpcI/bIO92Yq0WTqMIagCo= account: mediocregopher
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package dehub
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
// PayloadComment describes the structure of a comment payload.
|
|
type PayloadComment struct {
|
|
Comment string `yaml:"comment"`
|
|
}
|
|
|
|
var _ Payload = PayloadComment{}
|
|
|
|
// NewPayloadComment constructs a PayloadUnion populated with a PayloadComment.
|
|
// The Credentials of the returned PayloadUnion will _not_ be filled in.
|
|
func (proj *Project) NewPayloadComment(comment string) (PayloadUnion, error) {
|
|
payCom := PayloadComment{Comment: comment}
|
|
fingerprint, err := payCom.Fingerprint(nil)
|
|
if err != nil {
|
|
return PayloadUnion{}, err
|
|
}
|
|
return PayloadUnion{
|
|
Comment: &payCom,
|
|
Common: PayloadCommon{Fingerprint: fingerprint},
|
|
}, nil
|
|
}
|
|
|
|
// MessageHead implements the method for the Payload interface.
|
|
func (payCom PayloadComment) MessageHead(common PayloadCommon) string {
|
|
return `"` + payCom.Comment + `"`
|
|
}
|
|
|
|
// Fingerprint implements the method for the Payload interface.
|
|
func (payCom PayloadComment) Fingerprint(changes []ChangedFile) ([]byte, error) {
|
|
if len(changes) > 0 {
|
|
return nil, errors.New("PayloadComment cannot have any changed files")
|
|
}
|
|
return genCommentFingerprint(nil, payCom.Comment), nil
|
|
}
|